I'm sorry to flat out ask for someone to write my code for me but I've been tearing my hair out for nearly an hour trying to get the pivot operator to work in SQL.
I have the following results set:
SCCY AccountedPremiumCurrent AccountedPremiumPrevious
---- ----------------------- ------------------------
CAD 99111.0000 NULL
EUR 467874.0000 128504.0000
GBP 431618.3847 195065.8751
USD 1072301.1193 1171412.1193
And I need to pivot it around to this:
GBP USD CAD EUR
----------- ------------ ---------- -----------
431618.3847 1072301.1193 99111.0000 467874.0000
195065.8751 1171412.1193 NULL 128504.0000
I have a workaround which uses a union across two ugly "select max(case when...
" queries but I'd love to get this working with the pivot operator.
I feel like my brain cannot process the necessary logic to perform this operation, hence I'm asking for someone to help. Once I get this I'll be able to hopefully re-apply this like a pro...