简单查询
有表,其中数据如下:
id type name
------- --------------------- ----------
1 2007-06-01 df
2 2007-06-02 df
3 2007-06-01 sf
4 2007-06-02 sf
5 2007-06-03 sf
.......................................
现想查询出如下数据:
id type name
------- --------------------- ----------
2 2007-06-02 df
5 2007-06-03 sf
.....
试问改查询应该怎样写最好!
------解决方案--------------------select * from tablename a
where type=(select top 1 type from tablename where name=a.name order by type desc)