If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Taking the difference....9i

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-06-10, 09:44
shajju shajju is offline
Registered User
 
Join Date: Aug 2008
Posts: 298
Taking the difference....9i

Hi guys

I have a table with X number of columns (column type number) where entries come in every 15 min. The values that come in are cummulative.

I need to summarize these entries to an hourly basis so that the value shown at 1am shows the increment from the value that came in at 15 min past the hour.

So if,

Code:
DATETIME  COL1  COL2

1:00AM           2      10
1:15AM           3      15
1:30AM           4      20
1:45AM           5      25
2:00AM           6      30

After summarizing these values, I need the value at 2:00AM to show the values 3 and 15 like:

DATETIME COL1       COL2

2:00AM       3=(6-3) 15 =(30-15)
and so on.
I tried out the LAG function but the LAG function seems to apply to individual columns. I need to find the difference mentioned above for all X columns with one command, if possible.

Could someone advise please?

Regards
Reply With Quote
  #2 (permalink)  
Old 02-06-10, 11:34
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,151
Where to_char(datetime,'mi') = '00' or to_char(datetime,'mi') = '15'
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On