简单的SQL查询,大家都来看看(100分)

  • 主题发起人 主题发起人 gengxinxing
  • 开始时间 开始时间
G

gengxinxing

Unregistered / Unconfirmed
GUEST, unregistred user!
表table1 如下: <br>&nbsp;编号 &nbsp;时间 &nbsp; &nbsp; &nbsp; &nbsp; 类型<br>&nbsp; 1 &nbsp; &nbsp; 2008-01-02 &nbsp; 001<br>&nbsp; 2 &nbsp; &nbsp; 2008-10-01 &nbsp; 001<br>&nbsp; 3 &nbsp; &nbsp; 2008-05-10 &nbsp; 002<br>&nbsp; 4 &nbsp; &nbsp; 2008-06-01 &nbsp; 002<br><br>查询结果为<br>&nbsp; 1 &nbsp; &nbsp; 2008-01-02 &nbsp; &nbsp;001<br>&nbsp; 3 &nbsp; &nbsp; 2008-05-10 &nbsp; &nbsp;002<br>(即:查询出同类型的时间较小的记录)<br>请问查询语句要怎么写呢?
 
select 类型,min(时间) from table1 group by 类型
 
select a.* from Table1 a,<br>(select min(时间) as MinTime, 类型 from Table1 group by 类型) b<br>where a.时间=b.MinTime and a.类型=b.类型
 
谢谢芙蓉弟弟和李翔鹏:)
 
后退
顶部