发布网友 发布时间:2022-03-29 10:42
共2个回答
热心网友 时间:2022-03-29 12:12
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
热心网友 时间:2022-03-29 13:30
mySql中,升序为asc,降序为desc。例如: