The "stock sold by type" report shows a single quantity sold for the period of the report.
It would be useful to be able to produce a report showing how the amount sold varies over time. This would have stock types as rows, and after the row header would have date ranges as columns. Daily, weekly, monthly and yearly would all be useful date ranges.
Internally this report is going to be quite different to the "stock sold by type" report — it may as well be separate code.
(Implementation note: use a CTE to produce the date ranges for columns so we're not stuck doing min(date) and max(date) within each group.)
The "stock sold by type" report shows a single quantity sold for the period of the report.
It would be useful to be able to produce a report showing how the amount sold varies over time. This would have stock types as rows, and after the row header would have date ranges as columns. Daily, weekly, monthly and yearly would all be useful date ranges.
Internally this report is going to be quite different to the "stock sold by type" report — it may as well be separate code.
(Implementation note: use a CTE to produce the date ranges for columns so we're not stuck doing min(date) and max(date) within each group.)