I have a requirement to write a stored procedure that accepts a start date, end date and a frequency (day, week, month, quarter, year) and outputs a result set based on thos
select `date` as weekOf, sum(amt) from myTable where `date` between '2011-10-01' and '2012-01-01' group by week(`date` )