peggy83
peggy83

Reputation: 11

SQL Query for SSRS report

I would like to create an ssrs report as below -- I have the following columns to be displayed-

                    | Tickets   | Tickets   |
                    | scanned on| scanned on|
Attraction |   Hour | 09/08/2014| 09/09/2014| 09/10/2014| Day 4| Day 5| Day 6| 09/14/2014    
                      Monday       Tuesday     Wednesday ...................... Sunday

U Mueseum  | 9:00 AM |  10      |       40  |
            10:00 aM |
            ..
            ..
            ..
            ..
            ..
            23:00 AM

I will get the Start Date and End Date from the user. Now my problem is that I want a query for 7 days starting from the Start Date selected by the user to the End Date and for each hour i.e. for 1 day it would be 24 hrs, so 24*7 hours in total. When I display the value for scans in my current sql query it displays just for one day. How can I do it for 7 days, and the value of scans for that date should be displayed in the respective week day ie. Monday or Tuesday and so on. I am not able to get as to for each date and each hour the scan value changes, so I am confused and mixing up all here. The values for each hour on each day should be different and there is only one scan column, so how will the distinct values show up in the table.

I used the pivot table to convert the name of the week day from rows to individual columns.

Then the problem arises for ssrs report. How can this be executed in an ssrs report where the rows are for each hour and the columns displays the dates of the week selected. How can I achieve that in ssrs? I am getting currently for only 24 hrs, but i want the report to run for all 24 hrs for 7 days and should display the value side by side for each hour in each week day column.

Thank you.

Upvotes: 1

Views: 220

Answers (2)

Brad Hines
Brad Hines

Reputation: 107

You could do this pretty easily with a Date Dimension table and a PIVOT operator. Give that a try.

Upvotes: 1

Bobby
Bobby

Reputation: 2928

Pass in one parameter into your stored procedure called @StartDate.

In SQL create the @EndDate like this

DECLARE @EndDate DATETIME
SET @EndDate = DATEADD("d",7,@StartDate)

Return your date information in an hour and a day column. Then use the grouping feature in ssrs to display the data.

I hope this helps you get a bit further with your issue.

Bobby

Upvotes: 1

Related Questions