maximus1974
asked on
How to show the last employee that updated a record
I want to show only the last "EMPLOYEE" that updated in the record. In other words, the last employee date stamp in field dbo.WOLABO01B.date.
SELECT TOP (100) PERCENT dbo.WOMAST01B.step, dbo.WOMAST01B.wono AS WO, dbo.WOMAST01B.item AS PN, dbo.WOMAST01B.location,
dbo.WOMAST01B.dept AS SHOP, dbo.WOLABO01B.prempl AS EMPLOYEE, SUM(dbo.WOLABO01B.time) AS TIME, DATEDIFF(dd,
dbo.WOMAST01B.recdate, GETDATE()) AS [DAYS LEFT], dbo.WOMAST01B.tat
FROM dbo.WOMAST01B LEFT OUTER JOIN
dbo.WOLABO01B ON dbo.WOMAST01B.wono = dbo.WOLABO01B.wono
WHERE (dbo.WOMAST01B.dept = 'AVI')
GROUP BY dbo.WOMAST01B.step, dbo.WOMAST01B.wono, dbo.WOMAST01B.item, dbo.WOMAST01B.location, dbo.WOMAST01B.dept,
dbo.WOMAST01B.location2, dbo.WOLABO01B.prempl, DATEDIFF(dd, dbo.WOMAST01B.recdate, GETDATE()), dbo.WOMAST01B.tat
ORDER BY [DAYS LEFT] DESC
Capture.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Can you provide your expected result?
ASKER
is this statement correct?
LastDate = (SELECT TOP 1 [date] FROM dbo.WOLABO01B WHERE wono = woma.wono WHERE [date] IS NOT NULL ORDER BY [date] DESC)
FROM dbo.WOMAST01B woma
Getting syntax errors.
LastDate = (SELECT TOP 1 [date] FROM dbo.WOLABO01B WHERE wono = woma.wono WHERE [date] IS NOT NULL ORDER BY [date] DESC)
FROM dbo.WOMAST01B woma
Getting syntax errors.
ASKER
Expected result is no WONO duplicates and one employee which is the last one to clock in.
In your SELECT clause, I don't see any DATE column but in your screenshot, you have DATE as the last column after tat. Which column is displaying the DATE in your screenshot.