General information
Title:
Conditional Column names
Hi.
I am having trouble with syntax Of Transact Sql
I want to Select particular Column names, depending on the Data
Pseudoi Code is:
Select ;
MyFIled1, MYfiled2,MyFileld3,MyValue1,
Case:
If MyField1 = '10', MyValue1 as MyNewColumn01
If MyField1 = '20' MyValue1 as MyNewColumn02
If MyField1 = '30' MyValue1 as MyNewColumn03
Endcase
I also want to ensure that I ALWAYS end up with MyNewColumn01,MyNewColumn02,MyColumn03 even if of dont have the value in MyFileld1 (e.g. say I have only two rows with MyField1 = 1, and 2 I still want to create a zero column value called MynewColumn03
I know this can probably be done with the Pivot function, but can i do it with the Case id If statement ?
Tia
Gerard
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only