pg 分组 再进行组内排序 取组内第一个

partition by:进行分组

ORDER BY:进行排序

row_number:统计行数

 

select a.* from ( select *, "row_number"() over (partition by hall_id,center_frequency ORDER BY last_discover_time desc) as n from device_other where is_indoor) as a where n = 1

posted @ 2021-08-13 17:44  wangssd  阅读(1069)  评论(0编辑  收藏  举报