Question : SQL Query

Code below select the top 5 of all ..

I need top 5 customerNo but in every month

any ideas??
Code Snippet:
1:
2:
3:
4:
5:
SELECT     top 5 CustomerNo, SUM(TotalSales) AS MonthTotal, Date, MONTH(Date) AS MonthOrder, CAST(YEAR(Date) AS varchar) AS DateName
     FROM         V_Sales_MTD
     WHERE     (Date >= DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0)) AND (Date <= GETDATE()) OR
                            (Date > DATEADD(ms, - 3, DATEADD(yy, DATEDIFF(yy, 0, GETDATE()) - 1, 0))) AND (Date < DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0))
     GROUP BY CustomerNo, Date

Answer : SQL Query

Random Solutions  
 
programming4us programming4us