sql查詢表中最大值 在SQL中,如何查詢某一字段中最大值的數據?
在SQL中,如何查詢某一字段中最大值的數據?1、創建測試表,create table test_max2(id number, score number)2、插入測試數據,insert into te
在SQL中,如何查詢某一字段中最大值的數據?
1、創建測試表,create table test_max2(id number, score number)
2、插入測試數據,insert into test_max2 values(1001, 99)insert into test_max2 values(1002, 85)insert into test_max2 values(1003, 100)insert into test_max2 values(1004, 77)insert into test_max2 values(1005, 66)
3、查詢數據表,發現最大的score值為100;select t.*, t.rowid from TEST_MAX2 t4、查詢score值為最大(100)的記錄;select * from (select t.*, row_number() over(order by score desc) rn from TEST_MAX2 t) where rn = 1;