I am using a direct SQL query as a data source of my SSRS report:
SELECT
emp.EmployeeNumber, FirstName, LastName, MiddleName
, amts.AmountCode, amts.amt, amts.AmountType
from EmployeeMaster emp
LEFT OUTER JOIN
(
SELECT 'Earning' as AmountType, EmployeeNumber, EarningCode as AmountCode
, SUM(Amount) AS amt
FROM EmployeeEarnings GROUP BY EmployeeNumber, EarningCode
UNION ALL
SELECT 'Deduction', EmployeeID, DeductionID
, SUM(Amount) AS amt FROM EmployeeDeduction GROUP BY EmployeeID, DeductionId
) AS amts
ON emp.EmployeeNumber = amts.EmployeeNumber
This query gathers all the earnings and deductions per employee grouped by employee number, type of earning and type of deduction. I am unsure of whether I could do this in x++ or an AOT query. I am wondering if it is alright to do this, or is there be an alternative to produce a result like this query does? I am using RDP class.