I need a SQL query that returns the top 2 Plans by PlanDate
per ClientID. This is all on one table where PlanID
is the PrimaryID, ClientID
is a foreignID.
This is what I have so far -->
SELECT *
FROM [dbo].[tblPlan]
WHERE [PlanID] IN (SELECT TOP (2) PlanID FROM [dbo].[tblPlan] ORDER BY [PlanDate] DESC)
This, obviously, only returns 2 records where I actually need up to 2 records per ClientID
.