56,677
社区成员
发帖
与我相关
我的任务
分享
select A.id from A where A.identityid is not null order by A.date
id identityid credate memo
1 1 2011-01-02 00:00:00 test1
2 1 2011-01-01 00:00:00 test2
3 1 2011-01-21 00:00:00 test3
4 2 2011-01-01 00:00:00 test4
5 2 2011-02-01 00:00:00 test5
6 2 2011-01-01 00:00:00 test6
7 3 2011-01-11 00:00:00 test7
8 3 2011-01-08 00:00:00 test8
9 null 2011-01-01 00:00:00 test9
10 null 2011-01-01 00:00:00 test10
11 null 2011-01-01 00:00:00 test11
select A.id ,min(A.date)
from A
where A.identityid is not null
group by A.id
order by 2
select A.id from A where A.identityid is not null group by A.identityid order by A.date desc