SQL and Grouping
- From: gerryo <gerryo@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Jun 2005 07:27:06 -0700
This should be simple but I just can't get it. Please Help!
I have a table that contains hourly records, with a begin time and end time,
and a value field. I need to group these so they are not hourly anymore.
For example:
TABLE BEFORE
NAME BEGIN END VALUE
AGR1 1/1/2005 1:00:00 1/1/2005 2:00:00 10
AGR1 1/1/2005 2:00:00 1/1/2005 3:00:00 10
AGR1 1/1/2005 3:00:00 1/1/2005 4:00:00 10
AGR1 1/1/2005 4:00:00 1/1/2005 5:00:00 5
AGR1 1/1/2005 5:00:00 1/1/2005 6:00:00 5
AGR1 1/1/2005 6:00:00 1/1/2005 7:00:00 10
I need the results to look like this:
NAME BEGIN END VALUE
AGR1 1/1/2005 1:00:00 1/1/2005 4:00:00 10
AGR1 1/1/2005 4:00:00 1/1/2005 6:00:00 5
AGR1 1/1/2005 6:00:00 1/1/2005 7:00:00 10
Thanks in Advance,
Gerry O.
.
- Follow-Ups:
- Re: SQL and Grouping
- From: David Portas
- Re: SQL and Grouping
- Prev by Date: Is Stored Procedure and 'in' broken in MSDE 2000/SQL 2000 SP4?
- Next by Date: prompt for parameter in a view
- Previous by thread: Is Stored Procedure and 'in' broken in MSDE 2000/SQL 2000 SP4?
- Next by thread: Re: SQL and Grouping
- Index(es):
Relevant Pages
|
|