Domanda

My Output:

A   B   C   D       E       F
773 26  429 150000  500000  800000
773 26  117 150000  500000  800000
808 26  26  150000  500000  800000
809 26  26  150000  500000  800000

Need Output like below:

A   B   C   D   E   F
773 26  429 150000      
773 26  117 150000      
808 26  26      500000  
809 26  26          800000

I need column D E & F as shown above.Based on A Column Amount in D,E,F Should be displayed. How to acheieve this?

Thanks in Advance.

È stato utile?

Soluzione

you can use case to determine whether the value of the column or null should be returned

select 
    A
,   B
,   C
,   CASE A WHEN 773 THEN D ELSE NULL END AS D
,   CASE A WHEN 808 THEN E ELSE NULL END AS E
,   CASE A WHEN 809 THEN F ELSE NULL END AS F
from table_name
;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top