Hello everyone,
I have a table that records multiple "Meter Values" for multiple "Stations". Basically each Station can have up to 62 different Meters being recorded multiple time a day. The table will look like this
STATION_ID NUMBER
METER_ID NUMBER
METER_VALUE NUMBER
METER_DATE DATE
I need to be able to run a single SQL statement on this multi million row table that will give me something like this.
STATION_ID
METER_ID
TIME_FRAME (This would be Week to Date, Month to Date, Year to Date and Life Time)
sum(METER_VALUE)
Naturally on a table with many millions of rows I would like to do this with one pass through the table. I have been working with the group by ROLEUP and CUBE but not getting it. I can get it for every Week and every Month and Every Year. But I am after just the current.
Any help would be great. Thanks.