SELECT A.scph,A.wavelengthgrade,A.seq FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY wavelengthgrade ORDER BY seq DESC) RN,* FROM T) A
WHERE A.RN=1
表名换一下,我起的叫T
结果截图
--------------------------分隔线-------------------------
以上语句适用于sqlserver2005以上版本,你要是用的2000的话,用下边,同样是表名要替换一下
select t1.scph,t1.wavelengthgrade,t1.seq from
(select * from t a where (select count(*) from t b where a.wavelengthgrade=b.wavelengthgrade and b.seq>a.seq) <=1) t1,
(select * from t a where (select count(*) from t b where a.wavelengthgrade=b.wavelengthgrade and b.seq>a.seq) <=1) t2
where t1.wavelengthgrade=t2.wavelengthgrade and t2.seq
select top 1 * from 表名 where seq like 'L%' orde by Cast( right(seq,2) as int) desc
union all
select top 1 * from 表名 where seq like 'M%' orde by Cast( right(seq,2) as int) desc
看错题目 现在改成这样 行了
如下:
select max(seq) seq,WaveLengthGrade
from tabxxx
group by WaveLengthGrade
select max(列名) from 表
这样不行?试过没有?