我的查询结果如下:
empName project leavedate
abc pjt1 10/10/2013
abc pjt1 10/12/2013
abc pjt2 10/10/2011
基于上面的查询结果,我想获得他已经离开的每个项目的最新日期。它不是表格,它是查询结果。
答案 0 :(得分:0)
SELECT MAX(leavedate) FROM my_table_;
答案 1 :(得分:0)
SELECT t1.empName, t1.project, t1.leavedate
FROM <yourTable> t1
WHERE NOT EXISTS (SELECT * FROM <yourTable> t2
WHERE t1.project = t2.project AND t2.leavedate > t1.leavedate)
答案 2 :(得分:0)
试一试:
SELECT empName, project, MAX(leavedate)
FROM mytable
GROUP BY project;