56,678
社区成员
发帖
与我相关
我的任务
分享
'a','2016-3-1'
'a','2016-8-9'
'a','2015-7-3'
'a','2016-5-7'
'b','2013-3-4'
'b','2013-4-4'
'b','2013-3-4'
'b','2013-6-4'
'b','2013-5-4'
'c','2013-3-4'
'c','2013-6-4'
'c','2013-5-4'
'a','2016-8-9'
'a','2015-7-3'
'b','2013-6-4'
'b','2013-5-4'
'c','2013-6-4'
'c','2013-5-4'
SELECT t3.dtype,max(t3.cdate)cdate from a0310 t3
WHERE t3.id not in
(
SELECT t2.id from a0310 t2
left JOIN
(
SELECT a.dtype,max(a.cdate)cdate from a0310 a
group by a.dtype
)t1 on t1.dtype=t2.dtype
WHERE t2.cdate=t1.cdate
)
group by t3.dtype
union all
SELECT b.dtype,max(b.cdate)cdate from a0310 b
group by b.dtype
order by dtype,cdate desc