我有这个查询:
SELECT BLI.EmpID, ShortEmployees.EmpName1 AS EmpName, SUM(BLI.FinalValue) AS Total
FROM BLI
INNER JOIN BSR ON BLI.BLID = BSR.BLID
INNER JOIN ShortEmployees ON BLI.EmpID = ShortEmployees.EmpID
WHERE (CONVERT(varchar, BLI.BLDate, 112) >= CONVERT(varchar, CONVERT(datetime, '1/10/2012', 103), 112))
AND (CONVERT(varchar, BLI.BLDate, 112) <= CONVERT(varchar, CONVERT(datetime, '30/10/2012', 103), 112))
AND (BSR.BSTID = 2)
AND (BLI.State IN (2, 6, 8, 9, 10, 12, 18))
GROUP BY BLI.EmpID, ShortEmployees.EmpName1
ORDER BY Total DESC
我预计总数为 42,但我得到了 126 的三倍!
编辑:我的期望是错误的,查询返回正确的总和。