Populating report with select when there are too many zeros

  • 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."?

  • From what I gathered from your posting, this may be possible using a table on the fly.

    declare a table @table

    insert @table

    select values from table1

    insert @table

    select values from table2

    you can insert @table into @table2 with an update statement to make @table2 your final table look more presentable.

    Try reposting with detail examples I believe that will make it clearer for folks in here to help ya in case my reply did not make any sense either.

  • actually your reply did help, thanks. I didn't think of creating a new temporary table in a stored procedure to organize the data. now how could i write a stored procedure to group all the info i'm getting by day. let me say it like this. I've got a table that's going to have some columns full of numbers, all entries filled with an integer, because they are being given data every 5 minutes but some columns are going to be receiving data at a slower interval, maybe once a day, but they get stored in the same table so itll just have a bunch of zeros for the entries collected every five minutes except for one, thatll be the true data collected once a day. how can i consolidate all those entries for that day into one?

    im going to be looking more into creating a temporary table sam, thanks for the lead.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply