One method of actually using a Windows Function in a WHERE clause
WITH MahQuery AS ( | |
SELECT DummyId, | |
PartitionId, | |
ROW_NUMBER() OVER (PARTITION BY PartitionId ORDER BY DummyId DESC) AS LastN | |
FROM dbo.DummyTable | |
) | |
SELECT DummyId, | |
PartitionId, | |
LastN | |
FROM MahQuery | |
WHERE LastN <= 2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment