General information
Forum:
Microsoft SQL Server
Title:
How can I create crosstab table
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
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