【发布时间】:2017-01-19 04:31:14
【问题描述】:
表定义是这样的:
create table test_1
( match_id varchar2(30), ts timestamp );
match_id 为整数格式。[A|B],如 1.A、1.B、99.A 或 99.B。 match_id 在同一整数上的行称为一对,因此 1.A 和 1.B 是一对,而 99.A 和 99.B 是另一对。数据库是 Oracle 11.2 或更高版本。
SQL> insert into test_1 values ('1.A',current_timestamp);
SQL> insert into test_1 values ('1.B',current_timestamp-10);
SQL> insert into test_1 values ('100.A',current_timestamp-20);
SQL> insert into test_1 values ('100.B',current_timestamp-30);
SQL> insert into test_1 values ('99.A',current_timestamp-40);
SQL> insert into test_1 values ('99.B',current_timestamp-50);
我想按 match_id 列中整数值的降序选择此表,例如 100.B、100.A、99.B、99.A、1.B、1.A 但以下语句返回 99 .B、99.A、100.B、100.A、1.B、1.A。请提出建议。
SQL> select * from test_1 order by match_id desc;
【问题讨论】: