Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I create crosstab table
Message
From
28/08/2003 02:11:10
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
How can I create crosstab table
Miscellaneous
Thread ID:
00824089
Message ID:
00824089
Views:
46
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 .
Next
Reply
Map
View

Click here to load this message in the networking platform