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
 General SQL Server Forums
 New to SQL Server Programming
 display results differently

Author  Topic 

gbeford
Starting Member

9 Posts

Posted - 2009-04-22 : 12:56:43
Hello, I have a store procedure that displays my data like this

3/4/2009 12:00:00 AM Billing 1

3/4/2009 12:00:00 AM Repair Call – morning session 1

3/4/2009 12:00:00 AM Sales and Retention 1

put i want the data to come out looking like this
week total Billing 1 Repair Sales
3/4/09 213 39 52 43
3/11/09 105 46 25 34

can someone help me to modify this stored procedure ?

here is the store procedure

select CallAttended, DateAdd(day,-DATEPART(DW,CallDate)+ 4,CallDate) as Week_Value, count(* ) as Total
from TD_PRCA_Details with (nolock)
where CallDate between @StartDate and dateAdd(day,1,@StopDate)
group by CallAttended, DateAdd(day,-DATEPART(DW,CallDate)+ 4,CallDate)

nathans
Aged Yak Warrior

938 Posts

Posted - 2009-04-22 : 13:43:08
You can use this method to tab the sums:


select CallId,
sum(case when Type='Sales' then 1 else 0 end) [Sales],
sum(case when Type='Billing' then 1 else 0 end) [Billing]
...
from ...
group
by CallId


Nathan Skerl
Go to Top of Page
   

- Advertisement -