Click to See Complete Forum and Search --> : SQL Reporting Services and Select Query


jarxt8
10-06-2008, 11:07 AM
I need some help creating a report from this database that I've got. I'm using Microsoft SQL Server 2005. It's going to be populated with data coming in at different time intervals, so some columns will receive data at one time interval and other columns will receive it at a different time interval. Using this method a lot of columns are going to be receiving zeros as only one column might get updated. Not the way I wanted to do it, but its the boss's orders so I've got to figure it out.

Right now though, I am wondering how I can write a select statement so that I pull all the data out between two certain dates and consolidate that info by day, so lets say I want column A, C and E for the report and I want it between october 3rd and 6th. So I'd have 4 rows for Oct 3, 4, 5 and 6 with values in the columns once for each day, no zeros.

I hope I'm making sense with this question. Now is there a way to write this query or should I just go back to the boss and say "Hey, we need to make new tables based on time intervals instead of throwing it all into one table."?

lochgo
10-14-2008, 10:05 AM
The first question I have is how you are identifying the rows for Oct 3, 4, 5 and 6. Hopefully there is a column that references the date you are trying to pull. In which case, you can add the following to the SELECT statement:

WHERE date=3 OR date=4 OR date=5 OR date=6

If you know that the dates will always be consecutive, you could do it the following way:

WHERE date >= 3 AND date <= 6