sql查詢表中最大值 在SQL中,如何查詢某一字段中最大值的數(shù)據(jù)?
在SQL中,如何查詢某一字段中最大值的數(shù)據(jù)?1、創(chuàng)建測(cè)試表,create table test_max2(id number, score number)2、插入測(cè)試數(shù)據(jù),insert into te
在SQL中,如何查詢某一字段中最大值的數(shù)據(jù)?
1、創(chuàng)建測(cè)試表,create table test_max2(id number, score number)
2、插入測(cè)試數(shù)據(jù),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、查詢數(shù)據(jù)表,發(fā)現(xiàn)最大的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;