RNA RNB RNC
1
2
3
4
1 1 1
2 2 2
3 3
이렇게 하려면 어찌해야하나요?
WITH t AS ( SELECT 1 rna, null rnb, null rnc FROM dual UNION ALL SELECT 2, null, null FROM dual UNION ALL SELECT null, 1, null FROM dual UNION ALL SELECT null, 2, null FROM dual UNION ALL SELECT null, 3, null FROM dual UNION ALL SELECT null, null, 1 FROM dual UNION ALL SELECT null, null, 2 FROM dual UNION ALL SELECT null, null, 3 FROM dual UNION ALL SELECT null, null, 4 FROM dual ) SELECT MIN(rna) rna , MIN(rnb) rnb , MIN(rnc) rnc FROM t GROUP BY COALESCE(rna, rnb, rnc) ORDER BY COALESCE(rna, rnb, rnc) ;