日期:2014-05-17  浏览次数:20449 次

SQL中某一列的值为条件中最大的筛选
有一个表的结构
projectID   Project          version
1           projectA           1
1           projectA           2
1           projectA           3
2           projectB           1
2           projectB           2
3           projectc           1

能把最大的Version查出来吗.?
得到结果
projectID   Project          version
1           projectA           3
2           projectB           2
3           projectc           1
------解决方案--------------------
select projectID ,  Project,max(version)
from tb
group by 
projectID ,  Project
------解决方案--------------------
SELECT   Projectid,
         Project,
         Max(version)
FROM     tab
GROUP BY Projectid,
         Project

------解决方案--------------------
select projectID,Project,max(version) as version from tb group by projectID ,Project