April 9, 2008 at 11:55 am
Hi,
I have an accounting table with 5 year of data for an account, the table headers look as following
Acctno___Year___db_1,db_2,db,db_3,db4,….db_12,Cr_1,cr_2,cr_3…,cr-12
I want to with select statement to convert the data to query the header must be the following:-
Years1___Year2___year3___year4____year5
Db_1
Db_2
Db_3
.
.
.
Thanks for any help
April 23, 2008 at 3:38 am
Look up PIVOT in Books Online.
ML
---
Matija Lah, SQL Server MVP
http://milambda.blogspot.com
April 23, 2008 at 3:55 am
Or maybe even UNPIVOT, given the underlying data you seem to be describing there.
You should seriously consider storing your underlying data in a normalized structure...
http://support.microsoft.com/kb/283878
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply