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 |
|
NhanLe
Starting Member
3 Posts |
Posted - 2008-10-27 : 07:23:05
|
| Date happening duration11/11/2008 online 8:0011/11/2008 offline1 1:0011/11/2008 offline2 2:1011/11/2008 offline1 0:2012/11/2008 online 16:0012/11/2008 offline2 0:30How can I calculate for every day the duration of the online time? online - (sum(offline1)+sum(offline2)Result should be a resume for every day:date RealOnline11/11/2008 4:3012/11/2008 15:30Looking forward for your helpThanksNhan |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-27 : 07:28:54
|
| [code]SELECT DATEADD(dd,DATEDIFF(dd,0,Date),0),SUM(CASE WHEN happening ='online' THEN duration ELSE 0 END)-(SUM(CASE WHEN happening ='offline1' THEN duration ELSE 0 END)+SUM(CASE WHEN happening ='offline2' THEN duration ELSE 0 END))FROM YourTableGROUP BY DATEADD(dd,DATEDIFF(dd,0,Date),0)[/code] |
 |
|
|
NhanLe
Starting Member
3 Posts |
Posted - 2008-10-27 : 07:51:19
|
| dear visakh16,Thank you for the extremely fast response, looks very neat.Yet I've mistaken in the forum. I need the code for access 2003.U're great |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-27 : 07:59:25
|
quote: Originally posted by NhanLe dear visakh16,Thank you for the extremely fast response, looks very neat.Yet I've mistaken in the forum. I need the code for access 2003.U're great
then please post this in access forum. |
 |
|
|
|
|
|
|
|