Chartjs-How to write a query for sales by month of individual items

3👍

You would easily get this data using GROUP BY of r_vehicle and r_month

SELECT r_vehicle, r_month, COUNT (*)
FROM reservations
GROUP BY r_vehicle, r_month
ORDER BY r_vehicle, r_month;

In case you would have missing values in the reservations table where you are missing few month values, you would need to create a temp table with all month values and do a LEFT JOIN of this table with reservations table.

Leave a comment