SQL Server 2000General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
I have created a temp table (#TempTable) as follow...
DATE HOURS TYPE TIME_BEG TIME_END
Sep 1 2004 12:00AM 5.0 P 12.0 17.0
Sep 6 2004 12:00AM 2.0 W 0.0 0.0
Sep 6 2004 12:00AM 2.0 HP 17.0 19.0
Sep 6 2004 12:00AM 1.0 HP 19.0 20.0
Sep 6 2004 12:00AM 3.0 HP 20.0 23.0
Sep 9 2004 12:00AM 4.0 P 0.0 0.0
Sep 9 2004 12:00AM 11.0 HWO 6.0 17.0
Sep 9 2004 12:00AM 1.0 HWO 17.0 18.0
There are serveral creteria that I want before I could sum up the total hours.
1. Same date
2. Same type
3. Time_End must be equal to the Time_Beg of other record.
For example...
There are 3 records on Sep 6 2004 that matches the above creteria.
Sep 6 2004 12:00AM 2.0 HP 17.0 19.0
Sep 6 2004 12:00AM 1.0 HP 19.0 20.0
Sep 6 2004 12:00AM 3.0 HP 20.0 23.0
Therefore, I would like to group them together as follow...
Sep 6 2004 12:00AM 6.0 HP 17.0 23.0
Here is another example...
There are 2 records on Sep 9 2004 that matches the creteria.
Sep 9 2004 12:00AM 11.0 HWO 6.0 17.0
Sep 9 2004 12:00AM 1.0 HWO 17.0 18.0
Therefore, I would like to group them together as follow...
Sep 9 2004 12:00AM 12.0 HWO 6.0 18.0
I hope I have explained this clearly to all of you.
Thanks in advance!!