I have a report that displays the hours submitted by employees for the selected team during a given time period and breaks the hours down by service codes so I can group and total by billable and non-billable. We noticed that the numbers were not adding up and what seemed to happen is that the employee entered two half-hour entries under the same code for the same day but the query only returned one of the rows. I am not restricting the code by a DISTINCT so I don't understand why it would ignore the second row. I included the PK ID and the missing entry showed up. The code is a mess pulling from multiple tables but even if there are two or more rows with the identical entries it should not omit one unless I specified it to be unique or DISTINCT (?). Adding the PK has resolve the issue but now I worry that other reports might also be affected if SSRS is just omitting rows. I can't see anything in the code that would specify this behavior so I am assuming it is something with SSRS, a odd behavior I don't understand and have to do a workaround to avoid it.
Any insight into why this has happened so I can eliminate the potential for future errors would be greatly appreciated!!
SELECT EmpCustom.EmpCustValue AS Team, Employee.Emplevel AS Level, Employee.Empfname + ' ' + WIP.WEmpLName AS Employee, WIP.WCltName AS Project,
WIP.WCodeCat AS ServiceCategory, WIP.WCodeSub AS SubCategory, WIP.WCodeSer AS Service, ISNULL(WIP.Whours, 0) AS Hours, ISNULL(WIP.Wfee, 0) AS Amount,
ISNULL(WIP.Wdate, 0) AS Date, Department.DeptName AS TeamDept, EmpCustom.EmpCustValue AS TeamColour, WIP.ID
FROM WIP RIGHT OUTER JOIN
Employee ON WIP.WempID = Employee.ID INNER JOIN
Department ON Employee.Empdept = Department.DeptID INNER JOIN
EmpCustom ON Employee.ID = EmpCustom.EmpCustEmpId
WHERE (WIP.Wdate >= @StartDate) AND (Employee.ID > 1) AND (EmpCustom.EmpCustValue = @TeamColour) AND (WIP.Windicator <> 'D') AND (WIP.Wdate <= @StartDate + 6)
GROUP BY EmpCustom.EmpCustValue, Employee.Emplevel, Employee.Empfname, WIP.WEmpLName, WIP.WCltName, ISNULL(WIP.Wdate, 0), WIP.Whours, ISNULL(WIP.Wfee,
0), Department.DeptName, WIP.WCodeCat, WIP.WCodeSer, WIP.WCodeSub, WIP.ID
ORDER BY TeamColour, Level, Employee, ServiceCategory, Date DESC