oracle中选出某个字段里面最大值的记录的sql语句怎么写
展开全部
1、创建测芹册棚试表,
create table test_max(id number, value number);
2、插入测试数据
insert into test_max values(1,12);
insert into test_max values(2,100);
insert into test_max values(3,55);
insert into test_max values(4,100);
insert into test_max values(5,50);
commit;
3、查询表中全姿侍量数据,select t.*, rowid from test_max t;
4、编写嫌则sql,使用rank分析函数,取value值为最大的记录; select t.* from (select t.*, rank() over(order by value desc) rk from test_max t) t where rk = 1;
展开全部
实现例哗岩句如下:
SELECT a.*
FROM table1 a WHERE NOT
EXISTS (SELECT 1 FROM table1 b WHERE b.id>a.id)
或销简者亏芦裤
SELECT *
FROM table1 WHERE id IN
(SELECT Max(id) FROM table1)
又或者
SELECT *
FROM table1 WHERE id=(SELECT Max(id) FROM table1)
SELECT a.*
FROM table1 a WHERE NOT
EXISTS (SELECT 1 FROM table1 b WHERE b.id>a.id)
或销简者亏芦裤
SELECT *
FROM table1 WHERE id IN
(SELECT Max(id) FROM table1)
又或者
SELECT *
FROM table1 WHERE id=(SELECT Max(id) FROM table1)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询