请问简单sql语句,谢谢!
id tid createtime
1 2 2007-1-1
2 2 2007-1-2
3 3 2007-1-1
4 3 2007-1-2
...
按tid分组取createtime最小的id
谢谢
------解决方案--------------------select a.id,a.tid,a.createtime from tb a inner join
(select tid,min(createtime) createtime from tb group by tid) b
on a.tid=b.tid and a.createtime = b.createtime
------解决方案--------------------select t.* from tabname t where not exists(select 1 from tabname where tid=t.tid and createtime <t.createtime)