获取最大post_year组考虑到见下表通过电子邮件
Email Post_Year
====== ==========
[email protected] 2007
[email protected] 2008
[email protected] 2009
[email protected] 2010
我希望有最大Post_year组结果通过电子邮件
Email Post_Year
====== ==========
[email protected] 2008
[email protected] 2010
此代码不会因为[Post_Year]
工作不汇总操作having
部分
SELECT TOP (1000) *
FROM [DataExtraction2].[dbo].[Users]
group by [Email]
having max([Post_Year]) = [Post_Year]
如何达到目的?
在'select'中包含email和max(postyear),并从查询中删除'having'和'top'。 –