SQL cx的语法,意味着什么

时间:2016-08-03 02:21:27

标签: sql syntax

我有类似这样的SQL语法

WITH cx (Policy_Number,Claim_Incurred)

  AS (

    SELECT PolicyNo

      ,SUM(ReservedAmt + PaidAmt - SalvageAmt + ReservedExp + PaidExp - SalvageExp)

    FROM eInsurance.dbo.Claim

    GROUP BY PolicyNo

  )

或类似的东西

REFERENCE.dbo.FXRate fx
    JOIN eInsurance.dbo.PolicyM pm
      ON fx.currency = pm.PRCurrency
    LEFT JOIN cx
      ON pm.PolicyNo = cx.Policy_Number
    JOIN eInsurance.dbo.Account acc
      ON pm.AccCode = acc.AccCode
    JOIN eInsurance.dbo.AccTypeList atl
      ON acc.AccType = atl.TypeCode

那么cx在语法中意味着什么??

1 个答案:

答案 0 :(得分:1)

cx被称为公用表表达式,通常称为CTE。

您可以将其视为数据的临时视图,仅针对单个查询进行定义。您可以使用cx子句中的定义替换with