骑骡子赶猪  

 按名字分组,按时间排序

 

 

select * FROM (
select row_number() over (partition by NAME order by DAT desc) rn ,name,dat

FROM QWER

) tn where tn.rn=1;

SELECT a.* from QWER a,
(SELECT name,max(dat) dat FROM QWER GROUP BY name) b where
a.tim=b.dat
and
b.name=a.name;

 

posted on 2019-10-28 14:42  骑骡子赶猪  阅读(120)  评论(0编辑  收藏  举报