送分题,Oracle降序和升序
id name birthday
1 aa 1990-01-02 10:10:50
2 bb 1987-02-02 10:01:25
3 cc 2000-01-25 09:01:25
根据birthday字段的升序和降序写sql语句,是oracle 展开
1、创建测试表,
create table test_name(id varchar2(20),name varchar2(20), birthday date);
2、插入测试数据;
insert into test_name values(1, 'aa', to_date('1990-01-02 10:10:50','yyyy-mm-dd hh24:mi:ss'));
insert into test_name values(2, 'bb', to_date('1987-02-02 10:01:25','yyyy-mm-dd hh24:mi:ss'));
insert into test_name values(3, 'cc', to_date('2000-01-25 09:01:25','yyyy-mm-dd hh24:mi:ss'));
commit;
3、编写语句,根据birthday字段进行升序;
select * from test_name t order by birthday;
4、编写语句,根据birthday字段进行降序;
select * from test_name t order by birthday desc;
select * from table order by birthday asc 升序
select * from table order by birthday asc 顺序
select *
from table
order by birthday
birthday字段的降序
select *
from table
order by birthday desc