0

I have a set of sales numbers and am trying to rank them by week. The query works great, except that I end up with a week number. How can I convert that week number to a beginning of week date?

SELECT 

SUM(`Sales`) `Record`,
Week(`DateTime of Sale`),
'Sales Record' AS `Category`,
'Weekly' AS `Interval`

FROM `SalesTable`

GROUP BY 
DATE(`DateTime of Sale`)

ORDER BY  SUM(`Sales`) DESC 

LIMIT 2
  • Have you seen this answer? http://stackoverflow.com/questions/7078730/how-to-convert-number-of-week-into-date – BenB Jan 16 '15 at 00:10
  • I have, but the problem that I run into with that one is that it relies on the weekbeginning of the year starting on a hypothetical Jan 1st, which it does not for this year or any of the previous recent years I am aware of. So, if the year starts on Wednesday, then the solution to multiply by 7 to get the day number is off by three days. Thanks for the link though! :) – C. Michael Boegner Jan 16 '15 at 16:15

0 Answers0