需求: 先分組,再按時間排序,最後取分組第一條資料
利用oracle的開窗函數可以實作
以下是模闆sql ,自行替換
select t.*
from (select a.*, row_number() over(partition by 需要分組的字段 order by 更新時間 desc) rw
from 表 a) t
where t.rw = 1
利用oracle的開窗函數可以實作
以下是模闆sql ,自行替換
select t.*
from (select a.*, row_number() over(partition by 需要分組的字段 order by 更新時間 desc) rw
from 表 a) t
where t.rw = 1