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
MySQL排序 有时候很容易记混,我这里把他记录了下:
desc是降序
asc是升序(默认不写就是升序)
MySql语句:
1.带条件的排序
2.不带条件的sql直接排序
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)