您不能直接使用列名吗?喜欢..
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)