2016-07-20 69 views
-2

我有這樣合併成一排

HONS  S.S.C  H.S.C  APPLICANT_ID 

    null   null  H.S.C-1  1 
    null   S.S.C-1  null   1 
B.S.C HONS - 1 null  null   1 

表我想這樣

HONS    S.S.C  H.S.C  APPLICANT_ID 

B.S.C HONS - 1 S.S.C-1  H.S.C-1  1 

輸出會是怎樣呢查詢?

回答

0

這對我有用。希望這可以幫助 !

SELECT MAX(HONS) HONS, MAX(SSC) SSC, MAX(HSC) HSC, MAX(APPLICANT_ID) APPLICANT_ID FROM 
(
select null HONS, null SSC, 'HSC-1' HSC, 1 APPLICANT_ID from dual 
union 
select null HONS, 'SSC-1' SSC, null HSC, 1 APPLICANT_ID from dual 
union 
select 'BSC-HONS' HONS, null SSC, 'HSC-1' HSC, 1 APPLICANT_ID from dual 
);