-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to do aggregation grouped by calc result of timestamp?
PostPosted: Thu Jun 25, 2009 12:17 am 
Newbie

Joined: Wed Aug 09, 2006 5:19 pm
Posts: 2
I have a table with lots of system performance data, with the following columns:
IID: unique id
TIMESTAMPT ITIME: date/time when the data was collected
VARCHAR(16) ITYPE: type of data
INTEGER IVAL: data value

The class looks like:
class PerfData{
Date time;
String type;
int val;
}
When ITYPE="CPU", it means performance data of CPU.

Now I want to show average CPU usage in every minutes in the past 24 hours. It's easy to limit time to the last 24 hours. Problem is I need to do an aggregation on val, which will be avg(val). But what shall I do for the GROUP BY part?
How can I define a group by to group data of the same minute from HQL?

I will run the app on Oracle. If there's a general HQL way which can keep DB-independence, it will be great! But if it is too difficult, I won't mind to use Oracle-specific solution for now.

And the aggregation period is flexible, it can be 1 minute, 5 minutes, half hour, 1 hour, half day, 1 day, 1 week, 1 month, etc.

If you have done anything similar before, it will be greatly appreciated if you can share your experience.

Thanks!

Li


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.