I have a query that I'm trying to run that will select the last 2 records in a job activity table so that I can use the information to compare start and end dates. I did find a thread that I believed would help me
So using their syntax with my table/variables came up with the following:
SELECT [Position Number], [Act Start Date], [End Date]
FROM [Job Activity] AS d
WHERE [Position Number] In
(SELECT TOP 2 [Position Number]
FROM [Job Activity]
WHERE [Position Number] = d.[Position Number]
ORDER BY [Position Number] DESC);
I have test information in the table but I do have 1 position number that is listed 3 times and all 3 of those records are listing in the query when I want only 2 of them to list. Does anyone have any suggestions? Thanks!
So using their syntax with my table/variables came up with the following:
SELECT [Position Number], [Act Start Date], [End Date]
FROM [Job Activity] AS d
WHERE [Position Number] In
(SELECT TOP 2 [Position Number]
FROM [Job Activity]
WHERE [Position Number] = d.[Position Number]
ORDER BY [Position Number] DESC);
I have test information in the table but I do have 1 position number that is listed 3 times and all 3 of those records are listing in the query when I want only 2 of them to list. Does anyone have any suggestions? Thanks!