Hi,
I know this has been asked many times on threads but each one I read I don't understand what I have to do. I have copied the code below which I can relate to my own except I only have one table that I'm trying to get the values from i.e. t1. In this table I have want to get the top 5 values for each customer. Any further pointers would be great.
SELECT t1.*
FROM [MyTable] t1
WHERE t1.OrderDate In (select top 5 t2.OrderDate from [MyTable] t2 where t2.CustomerID = t1.CustomerID ORDER BY t2.OrderDate DESC);
Many thanks
GPM
I know this has been asked many times on threads but each one I read I don't understand what I have to do. I have copied the code below which I can relate to my own except I only have one table that I'm trying to get the values from i.e. t1. In this table I have want to get the top 5 values for each customer. Any further pointers would be great.
SELECT t1.*
FROM [MyTable] t1
WHERE t1.OrderDate In (select top 5 t2.OrderDate from [MyTable] t2 where t2.CustomerID = t1.CustomerID ORDER BY t2.OrderDate DESC);
Many thanks
GPM