I’m struggling a bit to get this working. I’ve got data loaded into a staging table (bulk insert) and then I’m trying to transform 3 unique IDs into a final table: 'SPGBBMBMI-USDFF--P-RGL---','SPGBBMBMI-USDFF--P-RGUX-- ', 'SPGBBMBMI-USDFF--NHRGUX--'
For each ID, I want to look at the [Index Key] and copy over the [Index Value] & [Daily Return] from the same row.
This is what I have so far (below). I think it’s going to be something like this, but I’m struggling a bit to get it working.
INSERT into InvexValues (Date, IndexName, IndexKey, IndexValue, DailyReturn) SELECT [Date of Index], [Index Name], [Index Key], [Index Value], [Daily Return] from (SELECT [Date Of Index], [Index Code], [Index Value] from IndexStaging where [Date Of Index] is not null AND [Index Key] in ('SPGBBMBMI-USDFF--P-RGL---', 'SPGBBMBMI-USDFF--P-RGUX-- ', 'SPGBBMBMI-USDFF--NHRGUX--')) as T1 pivot (max([Index Value]) for [Index Key] in ([SPGBBMBMI-USDFF--P-RGL---], [SPGBBMBMI-USDFF--P-RGUX--], [SPGBBMBMI-USDFF--NHRGUX--])) as T2
Thank you so much!!
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.