Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
lsy
Yak Posting Veteran
57 Posts |
Posted - 2006-11-09 : 19:27:34
|
There have 2 tables, each table contain of start_date and stop_date. i need to find out the time different between start_date and stop_date and sum it up according to workweek from 2 tables. here is my syntax but the figure seem incorrect.For exampletable 1start_date end_date4/1/2006 12:31:32 AM 4/1/2006 12:50:45 AM4/1/2006 01:23:12 AM 4/1/2006 01:30:01 AM4/15/2006 02:03:22 AM 4/15/2006 02:10:55 AMtable 2start_date end_date4/1/2006 01:11:32 AM 4/1/2006 01:20:25 AM4/1/2006 02:23:12 AM 4/1/2006 02:40:41 AM4/1/2006 03:03:22 AM 4/1/2006 03:10:55 AMmy result will be like thisworkweek tbl1 tbl213 1562 203515 453 0Here is my syntax!!SELECT FORMAT(start_date, 'ww', 1,2) AS workweek,sum(datediff("s", 1.start_date, 1.stop_date)), sum(datediff("s", 2.start_date, 2.stop_date)FROM table1 1, table2 2GROUP BY FORMAT(1.start_date, 'ww', 1, 2);pls advice!! |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-10 : 00:47:09
|
One thought for my previously posted suggestions...You are aware you have to substitute my table names @table1 and @table2 with your real table names in your environment?Peter LarssonHelsingborg, Sweden |
 |
|
lsy
Yak Posting Veteran
57 Posts |
Posted - 2006-11-12 : 21:35:14
|
if using UNION ALL, it will not seperate tbl1 and tbl2 result... tbl2 result will continue after tbl1 result... and the group by function is aggregate with other column. |
 |
|
|
|
|
|
|