有一个表结构:Num Char(1)
Grade Char(6)
Days DateTiem
数据如下:'1','1级','2007.01.02'
'1','2级','2007.01.03'
'1','3级','2007.01.04'
'2','1级','2007.01.02'
'3','1级','2007.01.03'
'4','1级','2007.01.04'
'5','1级','2007.01.05'
'2','6级','2007.02.01'
'2','5级','2007.02.02'
'3','6级','2007.02.02'
请问怎样写Select语句才能得到如下结果(提取最后那天的数据)?
'1','3级','2007.01.04'
'2','5级','2007.02.02'
'3','6级','2007.02.02'
'4','1级','2007.01.04'
'5','1级','2007.01.05'
answer :select table1.*
from table1,(select num,max(days) as Days from table1 group by num) t
where table1.num=t.num and table1.days=t.days
order by table1.num
url: http://community.csdn.net/Expert/topic/5413/5413030.xml?temp=.6341669
Grade Char(6)
Days DateTiem
数据如下:'1','1级','2007.01.02'
'1','2级','2007.01.03'
'1','3级','2007.01.04'
'2','1级','2007.01.02'
'3','1级','2007.01.03'
'4','1级','2007.01.04'
'5','1级','2007.01.05'
'2','6级','2007.02.01'
'2','5级','2007.02.02'
'3','6级','2007.02.02'
请问怎样写Select语句才能得到如下结果(提取最后那天的数据)?
'1','3级','2007.01.04'
'2','5级','2007.02.02'
'3','6级','2007.02.02'
'4','1级','2007.01.04'
'5','1级','2007.01.05'
answer :select table1.*
from table1,(select num,max(days) as Days from table1 group by num) t
where table1.num=t.num and table1.days=t.days
order by table1.num
url: http://community.csdn.net/Expert/topic/5413/5413030.xml?temp=.6341669