SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 GROUP BY DATE AND GET elapsed time
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

olibara
Yak Posting Veteran

84 Posts

Posted - 05/29/2012 :  17:29:37  Show Profile  Reply with Quote
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

Sweden
29156 Posts

Posted - 05/29/2012 :  19:00:37  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

India
48012 Posts

Posted - 05/29/2012 :  21:16:57  Show Profile  Reply with Quote
can there be breaks in between?

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000