Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conditional Column names
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Titre:
Conditional Column names
Divers
Thread ID:
01531714
Message ID:
01531714
Vues:
68
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform