请教一个sql语句(50分)

  • 主题发起人 主题发起人 woodlee
  • 开始时间 开始时间
W

woodlee

Unregistered / Unconfirmed
GUEST, unregistred user!
PART NUMBER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LASTUPDA<br>12345 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2007/12/30<br>12345 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2008/01/02<br>34567 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2007/11/22<br>34567 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2007/10/31<br>建立的VIEW TABLE要為<br>PART NUMBER &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LASTUPDATE<br>12345 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2008/01/02<br>34567 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2007/11/22<br>就是要取出每个PART NUMBER最近的一条记录,即LASTUPDATE是最近的.
 
SELECT to_char(MAX(LASTUPDA),'YYYY-MM-DD') &nbsp;FROM &nbsp;TABLE//查询最近时间<br>这个做条件就OK了.
 
select PART NUMBER, max(LASTUPDA) LASTUPDA from tb group by PART NUMBER
 
后退
顶部