Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I need help as I couldn't figure it out.I have a table which has 4 columns:Week ending, Resource Name, # of hours worked, Mgr NameJan 3, 2014 A 42 Mg1Jan 10,2014 B 45 Mg2Now, I need to figure it out how many resources worked >40 for a month(instead of week).Any thoughts?Please let me know. Thanks!
I need count, like how many resources worked more than 45hrs in a week. Thanks!
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2014-03-07 : 17:22:56
Do you want it by week or month? Your posts are conflicting. Basically, it is a simple group by query with a HAVING clause:
SELECT ResourceNameFROM @FooGROUP BY YEAR(WeekEnding), MONTH(WeekEnding), ResourceName HAVING SUM(HourWorked) > 45
nkpriya
Starting Member
34 Posts
Posted - 2014-03-07 : 17:34:22
I want it by month whereeas I have data by week.Category for Hrs would be based on 40hrs/weekI need result something like:MgrName, Month, [CategoryHrs],[ResourceCount]Mg1 Jan [>40] 2Mg1 Jan [=40] 3Mg1 Feb [>40] 10Thanks!