February 13, 2012 at 9:12 am
I need to turn this script into a pivot table. I need the statuses across the top, and jobs on the left with counts of the statuses under the statuses at the top. This is a request from management at the company and I have never done pivot tables before.
use ReportServer
go
Select C.Name AS ReportName,
CAST (E.TimeProcessing as int)/1000 as [AVG TimeProcessing_in_Seconds],
COUNT (E.Status) as [Subscription Count],
CAST (E.Status as varchar(50)) as Status,
datepart(hour, E.TimeStart) as ReportStartTime from dbo.ExecutionLogStorage E
inner join catalog C on E.ReportID = C.ItemID
and E.TimeStart > '2012-02-01 00:00:21.310'
and E.TimeEnd < '2012-02-07 23:59:59.310'
group by C.Name,CAST (E.Status as varchar(50)),
datepart(hour, E.TimeStart),
CAST (E.TimeProcessing as int)/1000 order by 4,5 desc
February 13, 2012 at 10:13 am
Jeff does a great explaining this here. http://www.sqlservercentral.com/articles/T-SQL/63681/[/url]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 13, 2012 at 10:33 am
Sean Lange (2/13/2012)
Jeff does a great explaining this here. http://www.sqlservercentral.com/articles/T-SQL/63681/[/url]
and a follow on here
http://www.sqlservercentral.com/articles/Crosstab/65048/
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
February 13, 2012 at 10:35 am
You could always have Reporting Services do the pivot... just drop a matrix onto your report...
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply