子查询中的访问别名

子查询中的访问别名,第1张

查询中的访问别名

您不能直接使用列名吗?喜欢..

SELECt Inc.OwnerIdName as OIN  ,(SELECT COUNT(*)    FROM Incident     WHERe CreatedOn BETWEEN '2011/1/1' AND '2011/1/31'    AND Incident.OwnerIdName = Inc.OwnerIdName ) as CasesOpened  ,(SELECt COUNT(*)    FROM IncidentResolution     WHERe ActualEnd BETWEEN '2011/1/1' AND '2011/1/31' AND Incident.OwnerIdName = Inc.OwnerIdName ) as CasesClosedFROM Incident Inc

如果要直接使用Alias,则必须在查询的早期进行此 *** 作,然后将其用于所有标量子查询。

SELECt INC.OIN  ,(SELECT COUNT(*)    FROM Incident     WHERe CreatedOn BETWEEN '2011/1/1' AND '2011/1/31'    AND Incident.OwnerIdName = INC.OIN ) as CasesOpened  ,(SELECt COUNT(*)    FROM IncidentResolution     WHERe ActualEnd BETWEEN '2011/1/1' AND '2011/1/31' AND Incident.OwnerIdName = INC.OIN ) as CasesClosedfrom (Select OwnerIdName OIN  FROM Incident) INc


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5640460.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存