简体   繁体   English

如何将不同记录中的记录与两个不同列中的匹配数据排序为输出中的连续行

[英]How to order the records from different records with matching data in two differents columns as continous rows in output

Need help with Oracle query which will provide the output in below the format.需要有关 Oracle 查询的帮助,该查询将提供以下格式的输出。

Sample table样品表

c1 c2 c3 c4
-- -- -- -- 
 A  1 A1
 B  2 B1 C1
 D  6 E2 A1
 A  2    A1
 C  3 C1
 D  4 D1 E1

I want to join same table where data in 3rd Column matches the data in 4th and expecting the data to be sorted as subsequent records as below我想加入同一个表,其中第 3 列中的数据与第 4 列中的数据匹配,并希望将数据排序为后续记录,如下所示

c1 c2 c3 c4
-- -- -- -- 
 A  1 A1
 A  2    A1
 D  6 E2 A1
 B  2 B1 C1
 C  3 C1

That's not a grouping, it's a sorting that you need:这不是分组,而是您需要的排序:

select *
from your_table
order by coalesce(col1,'ZZZ') desc, 
                  col2 desc --coalesce will use 'ZZZ' to order if column is null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM