select * from table order by value1,value2
select * from table order by value1,value2 desc
按照降序排序
1、创建测试表,
create table test_order(id number, value1 number, value2 number)
2、插入测试数据
insert into test_order values(1,1001,2001)
insert into test_order values(2,1002,2002)
insert into test_order values(3,1003,2003)
insert into test_order values(4,1004,2004)
insert into test_order values(5,1005,2005)
3、查询表中所有记录数,select t.*, rowid from test_order t,
4、编写sql,按value1字段做升序,按value2字段做降序,
select t.*,
row_number() over(order by value1) rn1,
row_number() over(order by value2 desc) rn12
from test_order t
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)