SQL RollUp SubQuery

D

David

Never did a subquery so HELP?

I'm trying to go a query where I can specify a period (say a day) and have a
sub period (say 30 minutes) reflected within that daily query.

For example the resulting query table would look like:

Date Beg High Low End

11/9/2008 9:30:00 AM Values
11/9/2008 10:00:00 AM Values
11/9/2008 10:30:00 AM Values


I've written the query to rollup my data for the above 30 minute period.
It is:

PARAMETERS [pDateBeg] DateTime, [pDateEnd] DateTime;
SELECT FIRST(fldHistBeg) AS fldBeg, MAX(fldHistHigh) AS fldHigh,
MIN(fldHistLow) AS fldLow, LAST(fldHistEnd) AS fldEnd
FROM tblTest
WHERE (fldHistDateTime) BETWEEN [pDateBeg] And [pDateEnd];

QUESTION:

How do I merge the the above query (assume this would be a subquery) within
another query -- such that I can specify the day of interest (would require
another set of Parameters) and return the correct table by period (here 30
minutes) needed?

Is there a better way?
 
L

Lord Kelvan

ok i am not sure if i am clear

if you have the values

11/09/2008 9:25:36
11/09/2008 9:30:22
11/09/2008 9:31:30
11/09/2008 9:36:34
11/09/2008 9:57:55
11/09/2008 10:02:23
11/09/2008 10:27:56
11/09/2008 10:33:00

and you specified

as the day

11/09/2008

and 30 min period

9:30 - 10.00

you would want the results

11/09/2008 9:30:22
11/09/2008 9:31:30
11/09/2008 9:36:34
11/09/2008 9:57:55
11/09/2008 10:02:23
11/09/2008 10:27:56

to be displayed

is this correct

Regards
Kelvan
 
D

David

My other post didn't seem to get posted so this is a dup.

Using your value example the result should look like:

11/09/2008 9:30:00
11/09/2008 10:00:00

My SQL would rollup each 30 minute time period.
What I need is the SQL to rollup Multiple 30 minute periods.

Thanks
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top