I'm trying to generate a report that shows how many Expense Reports (ERs) and the total of those reports for each employee for FY18. The result set I have now has several duplicate UIN numbers--which is the identifying ID number for employees. There should only be one record for each UIN. I was thinking it had to do with the Group By and Order By clauses, but not sure. Can someone point out the problem area? Here's the SQL:
select x.er_employee_number "UIN",
x.er_user_full_name,
x.er_user_location,
count(X.ER_DOCUMENT_ID) "Number of ERs",
sum(X.ER_TOTAL_EXPENSE) "ER Total"
from INFOR.ALER_EXPENSE_EXPORT_HEADER@TEMPROD x
where X.EXPORT_HDR_STATUS like '4'
and X.ER_PURPOSE like 'Employee%'
and NEW_TIME(X.EXPORT_HDR_STATUS_DATETIME, 'GMT', 'CST') > to_date('1-Jul-2017')
and NEW_TIME(X.EXPORT_HDR_STATUS_DATETIME, 'GMT', 'CST') < to_date('30-Jun-2018')
group by x.er_employee_number,
x.er_user_full_name,
x.er_user_location,
X.ER_DOCUMENT_ID,
X.ER_TOTAL_EXPENSE;