Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I create crosstab table
Message
De
28/08/2003 02:11:10
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
How can I create crosstab table
Divers
Thread ID:
00824089
Message ID:
00824089
Vues:
44
Hi
I have a table like this

DocId | FieldName | FieldValue|
1 | Ddate | 01.01.2003|
1 | Dnum | 10 |

How can I get a new cursor like this cursor

DocId | Ddate | Dnum |
1 |01.01.2003 | 10 |

I knew the method with CASE WHEN structure

select docId,max(Case Fieldname when 'Ddate' then Fieldvalue ELSE '' END) as Ddate,max(Case Fieldname when 'Dnum' then Fieldvalue ELSE '' END) as Dnum from mytable group by docid

Is there anyone to knew the better method than it ?

Thanks .
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform