I want to select data from following table group by weeks
Date Product Name Sale +----------+--------------+-----+ 14-05-11 a 2 14
I think this should do it..
Select ProductName, WeekNumber, sum(sale) from ( SELECT ProductName, DATEDIFF(week, '2011-05-30', date) AS WeekNumber, sale FROM table ) GROUP BY ProductName, WeekNumber