views:

167

answers:

1

Using this example found here

I have a report i want to create which will show me infomation like the following:

Account ID , DateEntered, DateFirst contact was made, Dealt by, Date 2nd contact was made, Dealt by....

However all this information is heald in one table but the info comes like this (See example in link)

Now i would like to see the data like this in a linear fashion:

123 12-04-07 John 14-04-07 Mary 15-06-07 Cait

However differnt accounts will have different amounts of data in it so some may have 5 rows othere could have ten?

I would like to display data in a linear fashion so that each row is unique. In the case of the example, the unique identifier would be the accountID. My personal scenario is a bit different in that I have the data in several tables but can easily join them to get a similar output to the above example. Where I am having trouble is making the data linear so that each row is unique and does not repeat for each different variance.

Can this be done?

+1  A: 

You haven't mentioned which SQL Server version are you using or the number of rows are fixed or not for each account id. The above information restricts which solution needs to be used and these below will help you achieve what you want or reply back with additional details.

http://www.simple-talk.com/community/blogs/andras/archive/2007/09/14/37265.aspx http://sqlserver2000.databases.aspfaq.com/how-do-i-create-a-cross-tab-or-pivot-query.html http://www.mssqltips.com/tip.asp?tip=1019

Sankar Reddy
All of the PIVOT examples I've looked at use some aggregate function to tally the count or sum or max or whatever for the pivot table. I'm looking for a final result set with "n" number of columns for each row based on how many related records there are.
Eppz