可能重复:
sql server 使用计算列
有没有办法做到这一点:
select Name,
(SELECT Max(reference)
from Rematch
WHERE Gender='M' and convert(varchar,getdate,103) = '08/10/2012'
) As MaxReferenceMale,
(SELECT Max(reference)
from Rematch
WHERE Gender='F' and convert(varchar,getdate,103) = '08/10/2012'
) As MaxReferenceFemale
WHERE (Gender='M' and Reference > MaxReferenceMale) Or
(Gender='F' and Reference > MaxReferenceFemale)
我意识到可能有更好的方法来编写查询。是否可以在 WHERE 子句中引用 MaxReferenceFemale 和 MaxReferenceMale?