I am running this query in SQL Server so that only ONE employeeID shows the employee's salary, not each entry of the employeeID. This works as it should in SQL Server -> but for the life of me I can not discover how to re-write this in access.
What would be the access query syntax to achieve this same result?
Code:
;WITH data AS
(
SELECT [empName], [empID], TR = SUM([empSal]) OVER (PARTITION BY [empName]),
r = ROW_NUMBER() OVER (PARTITION BY [empName] ORDER BY [empName])
FROM employee
WHERE [empID] IS NOT NULL
),
All As
(
Select
[empName]
,[empID]
,[PayrollDate]
,[DepositDate]
FROM payroll
WHERE [empID] IS NOT NULL
)
SELECT
[empName] = aj.[empName]
,[empID] = aj.[empID]
,[payrolldate] = aj.[PayrollDate]
,[empSal] = ROUND(COALESCE(CASE r WHEN 1 THEN TR END, 0),0)
FROM allempID aj
LEFT JOIN data d
ON aj.[empID] = d.[empID]
GROUP BY aj.[empName], aj.[empID], aj.[PayrollDate]