答案 0 :(得分:2)
Select num,id, date
FROM
(
Select *, ROW_NUMBER() OVER(partition by num,id Order by date desc) as rnk
FROM source_table
)a
WHERE rnk = 1;
答案 1 :(得分:0)
通过使用相关的子查询
select * from your_table t
where t.date= (
select max(date) from your_table t1
where t1.num=t.num and t1.id=t.id
)
您可以使用max()
函数
select num,id,max(date) from your_table t
group by num,id
答案 2 :(得分:0)
SELECT NUM,ID,DATE FROM TABLE_TEMP
QUALIFY RANK OVER(PARTITION BY NUM,ID ORDER BY DATE DESC)=1;
您可以使用单行查询来完成
从TABLE_TEMP中选择NUM,ID,DATE 合格排名(按NUM排序,按日期DEDES排序ID)= 1;