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;