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.
| Author |
Topic |
|
cgreene.gsu@gmail.com
Starting Member
1 Post |
Posted - 2008-10-17 : 09:16:31
|
| I have 3 tables that i am trying to join to create one gridview that shows a detailed count of different items. My gridview works fine when it only joins two tables but when i add the third table it throws my counts completely off here is my code. If you have any suggestions on how to work this please let me know. thanks in advance. CmdStr = "SELECT UPPER([bpset_tckts].[rep_id]) as [Person Assigned], UPPER([tracker_users].[name]) As [Specialist Name], " + "COUNT(CASE WHEN ticket_type = 'EWTS Escalation Tracker' THEN 1 else NULL end) as [Escalations from EWTS], " +"COUNT(DISTINCT CASE WHEN ticket_type = 'CTMS' THEN 2 else NULL end) as [Tickets from CTMS Queues], " + "COUNT(DISTINCT CASE WHEN ticket_type = 'BWTS Escalation Tracker' THEN 3 else NULL end) as [Tickets from Old Tracker], " +"COUNT(DISTINCT CASE WHEN ticket_type = 'EHC' THEN 4 else NULL end) as [EHC Tickets], " + "COUNT(DISTINCT CASE WHEN ticket_type = 'Service Desk' THEN 5 else NULL end) as [Service Desk Tickets], " +"COUNT (distinct[wipbins].[ID_NUMBER]) as [Total WipBin Tickets], " + "COUNT(distinct [ticket_number]) as [Total Tickets] " +"FROM [bpset_tckts] with (NOLOCK) INNER JOIN [tracker_users] " + "with (NOLOCK) ON [bpset_tckts].[rep_id]=[tracker_users].[rep_id] " +"JOIN [wipbins] with (NOLOCK) ON [tracker_users].[wipbin]=[wipbins].[CASE_WIP2WIPBIN] " + "where [bpset_tckts].[picked_up] BETWEEN @date AND @endate group by [bpset_tckts].[rep_id], [name]"; |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-17 : 09:43:00
|
| show some sample data from tables and specify how they are related by giving the expected output. |
 |
|
|
|
|
|