Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Dynamic Columns In SQL Server

Author  Topic 

12many
Starting Member

9 Posts

Posted - 2013-01-18 : 11:40:35
Hi There

I would like to know if it is possible to dynamically build the columns in your report.

this is what i want to do.

I have three tables Trips, Aid And Service that i would like to join
The Trips table is just a list of trips all trips have service but not necessarily aids. The aid and service tables are code tables (Code,Description).

I would like to be able to write a report that Lists the aid vertically and then the services horizontally in the services column i would like to know how many times an aid appears in the trips table under each service?

imagine

Aids serv1 serv2 serv3 serv4
aid1 1 2 3 4
aid2 3 1 2 5
aid3 4 2 1 2

I did find Cross Joins but im not really sure that was what i wanted.
And lots of places pretty much said i would have to create a table and join with that.

many Thank

Ian

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-18 : 13:44:53
just bring data by joining tables in report and use a matrix container

use aids field as rowgroup and service field as column group

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -