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 2000 Forums
 SQL Server Development (2000)
 Dynamic Column creation for sales from month to month comparison

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-02-25 : 07:45:27
Jeff writes "I have a list of Distributors in a customer table. These distributors earn volume. Several distributors attended a meeting in LA in say Oct(MeetingID is 1 from Meeting Table). From a Commission table we track the volume earned by each Distributor by commission date. I need a query that pulls the data in such a way that we can see the month previous to Octobers volume as well as all other months to the current month in order to track the volume trends.
The for tables involved are Meetings, MeetingAttend, Customer, Commrec

Meeting
1.MeetingID
2.MeetingDate
3.MeetingName

MeetingAttend
1.MeetingID
2.CustID

Customer
1.custid
2.Name

Commrec
1.custid
2.DateEntered
3.PVolume


From these tables the report header needs to be:
Meeting.MeetingName,Customer.custid,Customer.Name, Commrec.DateEntered as PrevMonth,Commrec.PVolume as PrevMonthPV,
Commrec.DateEntered as MeetingMonth, Commrec.PVolume as MeetingMonthPV, etc...,commrec.DateEntered as CurrentMonth, commrec.PVolume as CurrentMonthPV


I can get the information to line up as
LA,1111,John Smith,September,25
LA,1111,John Smith,October,27
LA,1111,John Smith,November,31
etc.
I don't know how to do it across the Header linearly with Dynamic header names and have the data line up vertically instead of horizontally.

Any direction of where to even look or the name of the command to use would be most helpful.
Thanks"

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-02-25 : 09:23:07
I'm not completely sure of what you are asking, but it looks like you need to do a article/forum search here for DYNAMIC CROSS-TAB.
Go to Top of Page
   

- Advertisement -