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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 GROUP BY DATE AND GET elapsed time

Author  Topic 

olibara
Yak Posting Veteran

94 Posts

Posted - 2012-05-29 : 17:29:37
Hello

I have a select that will give me the activity per worker per hour

SELECT
Worker,
Weight,
Date
FROM
PRODUCTION
ORDER BY Worker,Date

I need get the Production per worker per Day

SELECT
Worker,
SUM(Weight) AS TotWeight,
CAST(Date AS DATE) AS Date
FROM
PRODUCTION
ORDER BY Worker,Date

But I need to get the elapsed time per day for each worker

Can I do that in SQL with such Query ?
Thank for your help

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-05-29 : 19:00:37
DATEDIFF(MINUTE, MIN(Date), MAX(Date)) AS Interval


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-29 : 21:16:57
can there be breaks in between?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -