如何在Oracle中查询排序后的第一条记录

其实就是分页查询的另一种应用:
select * from (
select tb.*, rownum from table_name tb where column_name like '20080311%' order by id)
where rownum=1

select * from (select * from <table> order by <key>) where rownum=1;

select * from (select * from <table> order by <key> desc) where rownum=1;


oracle中选出某个字段里面最大值的记录的sql语句怎么写?

2种写法:
select max(testfld) from test_table;

select testfld from test_table
 where rownum = 1
 order by testfld desc;

一般只用第一种就行了。




猜你喜欢

转载自blog.csdn.net/xiaobing_122613/article/details/80317913