我有一个用于从 SQL 数据库导出数据的 C# 应用程序。它从视图中提取数据并将其导出到 Excel 以导入我们的工资系统。我需要计算加班费。我有以下代码,但它不计算加班量。我已经在互联网上搜索了解决方案,但没有任何运气。
SELECT [Co Code]
, [Empl No]
, [Task CD]
, [Day No]
, [Fund Co Code]
, [Job No]
, [Equip Cost Cde]
, SUM([Reg Hrs Jc]) AS [Reg Hrs Jc]
,(CASE WHEN [Reg Hrs Jc] > 40 THEN [Reg Hrs Jc] - 40 ELSE 0 END) AS [Ot Hrs Jc]
FROM dbo.MIS_FTTIMECARD_OT
WHERE ([Date Worked] BETWEEN '8/11/2013' AND '8/17/2013')
GROUP BY [Co Code]
, [Empl No]
, [Task CD]
, [Day No]
, [Fund Co Code]
, [Job No]
, [Equip Cost Cde]
, (CASE WHEN [Reg Hrs Jc] > 40 THEN [Reg Hrs Jc] - 40 ELSE 0 END)