2
我需要獲取月度報告的數據,該數據應該排除星期日在所有星期......我無法排除星期日。請檢查下面的查詢:查詢查找本月的第一天和最後一天,不包括星期日在sql
select Name,Actual_Hours,round((Actual_Hours/((DATEDIFF(DAY,'12-01-2016' ,'12-14-2016')+1)*8.5))*100,0)as percentage
from (select Name , SUM(actual_Hours) Actual_Hours
from (select Name,ACTUAL_HOURS=sum(DATEPART(hh,[Time_Taken_in_Min]))+sum(DATEPART(MINUTE,[Time_Taken_in_Min])) /60
FROM [HR_Admin].[dbo].[Mst_Daily_Report_Pds] where date between '12-01-2016' and '12-14-2016' and (DATENAME(weekday,Date)) not in ('sunday')
GROUP BY Name)o group by Name )a order by Actual_Hours desc
此外,還只保留標籤與問題相關的標籤 – Spidey