select id,r,sr,kbn from (
select distinct id
,row_number()
over(partition by id order by r
desc)
rn,row_number()
over(partition by id,r order by sr
desc)
rn2,row_number()
over(partition by id,r,sr order by kbn
desc)
rn3,r
,sr,kbn
from test_soukou
)where rn = 1 and rn2=1 and rn3=1
--order by id,v1,v2,v3
select a.id, a.r, a.sr, max(kbn) as kbn
from
(select t.id, t.r, max(sr) as sr
from (select id, max(r) as r from test_soukou group by id) t1, test_soukou t
where t1.id = t.id and t1.r = t.r group by t.id, t.r
) a, test_soukou b
where a.id = b.id and a.r=b.r and a.sr=b.sr group by a.id,a.r,a.sr
取多列資料的最大值 最小值 sql
實現方法 實現sql語句 最大 select key 0,greatest x,y,z as max from greatests 實現sql語句 最小 select key 0,least x,y,z as min from greatests greatest 函式返回在該組輸入引數 n1,n2...
oracle 資料庫對於多列求最大值
1.案例 select greatest 36 55 34 v max,least 36 55 34 v min from dual oracle比較一列的最大值或者最小值,我們會不假思索地用max和min函式,但是對於比較一行的最大值或最小值呢?是不是日常用的少,很多人都不知道有oracle也有內...
對於Oracle所有列裡面獲取最大值
例 id pid sid 1 2 3 4 5 6 7 8 9 結果 id pid sid max id 1 2 3 9 4 5 6 9 7 8 9 9 測試資料 with test as select 1 id,2 pid,3 sid from dual union all select 4 id,...