Lance, My performance monitor aggregates frequent samples into smaller tables using this method. I create a function then write a query using the function and pass in the date column. The group by averages the values for me.
CREATE OR REPLACE FUNCTION nearest_even_hour (p_date IN DATE) RETURN DATE AS l_date DATE; BEGIN IF MOD(TO_NUMBER(TO_CHAR(TRUNC(p_date, 'HH24'), 'HH24')), 2) = 0 THEN l_date := TRUNC(p_date, 'HH24'); -- truncate to hour ELSE l_date := TRUNC(p_date, 'HH24')+1/24; -- round to hour and add one END IF; RETURN l_date; EXCEPTION WHEN OTHERS THEN RAISE; END; insert into SOME_TABLE ( select avg(value), nearest_even_hour(date_column) from OTHER_TABLE group by nearest_even_hour(date_column)); - Ethan -----Original Message----- Sent: Thursday, January 24, 2002 12:55 PM To: Multiple recipients of list ORACLE-L I am not sure how to ask this or if it is even possible. I have a stored procedure that runs every five minutes and writes the data to a table. I want to query every thirty minutes and group the rows from the last half our. would I used date difference? Thank you in advance lance -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Lance Prais INET: [EMAIL PROTECTED] Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Post, Ethan INET: [EMAIL PROTECTED] Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).