Skip to content
Advertisement

Using Column Alias as Values in other columns of table in Case statement

I have a sql table that has columns FundId, BreakdownName, BreakdownType and BreakdownValue

I want result table show fundid and Breakdownvalue as alias of combination of breadkdownname and breakdowntype

so for example, above table should result into

I tried doing it with case statement as

But this is giving me multiple rows for fund. First row has value for CashLong but CashNet is null. Second row has value for CashNet but CashLong is null. I want to have them in single row.

I tried doing it using temp table and insert but same result.

Can someone please help me with it?

Advertisement

Answer

Pretty sure you can do easily with conditional aggregation. Something like this.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement