Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Summing a a field by Date and Day

$
0
0

How would I add up my "labor hours" column by day so that I can pull a total from it measure for an overtime column?

Here is my query.....


SQL
UseReportingSELECTCalendarDate,Mth,Dy,LEFT(SUM(ActualLaborMinutes/60),5)ASLaborHoursFROMfactJobLaborJJOINdimDateDONJ.TranDateID=D.DateIdJOINdimCostCenterCONJ.CostCenterID=C.CostCenterIDWHEREJ.EmployeeID=9--@EmployeeEmployeeNameandD.Yr='2014'groupbyCalendarDate,Mth,Dy,MthID,ActualLaborMinutesorderbyD.MthIdasc
and an example of my results
CalanderDate Mth Dy LaborHours
2014-01-02 Jan Thu 0.116
2014-01-02 Jan Thu 0.616
and so on...

Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>