I am trying to make a SQL query in Server 2008 R2 that selects the rows only for employees who have over 40 hours in a pay week and a pay description that doesn't include "over time". So far I have the following:
SQL
WITHRESULTSAS(SELECT[FullName],[PayHours],[SSN],[EffectiveDate],[PayDescription],[OrderNumber],[WeekStart],[WeekEnd],SUM(PayHours)OVER(PartitionBYFullName,WeekStart)ASTotalHoursFROM[viewReportPotentialOverTime]WHEREEffectiveDateBETWEEN'01/01/2015 00:00:00'AND'10/16/2015 23:59:59'GroupByFullName,SSN,WeekStart,WeekEnd,EffectiveDate,OrderNumber,PayDescription,PayHours)SELECT*FROMRESULTSWHERETotalHours40--AND PayDescription !='Overtime Pay'OrderByFullName,WeekStart,EffectiveDate