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)
 Cross Tab Query question

Author  Topic 

DeveloperIQ
Yak Posting Veteran

71 Posts

Posted - 2009-10-28 : 19:04:35
I need help with solving the query below in SQL 2005
I have three tables like this:
1. Source with data as
1 ABC
2 DEF
3 GHI ....
2. Type with data as
1 Type1
2 Type2
3 Type3
3. Customer with data as
CustID FirstName LastName SourceID TypeID
1 John Doe 1 1
2 John Doe 1 2
3 Jane Doe 1 1
4 Jane Doe 2 1
5 John Doe 2 2
6 John Doe 2 1 ....
The goal is to get a cross tab report which will return the count of intra and inter duplicates for each source based on the source and types selected

For example, a user can select a one or more types and one or more sources and would like to see a report like this
ABC DEF GHI
ABC 1 1 0
DEF 0 0 0
GHI 0 0 0
   

- Advertisement -