Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conditional Column names
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Databases
Title:
Conditional Column names
Miscellaneous
Thread ID:
01531714
Message ID:
01531714
Views:
67
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
Map
View

Click here to load this message in the networking platform