请问如何筛选出每个LOTID下CleanTime的一笔资料?
谢谢
------解决方案--------------------
select * from
(select *,row_number() over(partition by LOTID order by CleanTime) 'rn'
from [表名]
) t where rn=1
------解决方案--------------------
用row_number函数就可以了哈,非常简洁:
select *
from
(
select *,
row_number() over(partition by LOTID order by CleanTime desc) as rownum
from tb
) t
where rownum=1