My issue
i am trying to solve this problem but there is issue in order by query. it does not ordered by the months
My code
/* Write a query to output the following
- product_id, units_sold and month of sale for all high margin products sold in the year */
-- SELECT
-- dps.product_type,
-- dps.product_id,
-- dps.units_sold,
-- ms.month
-- FROM
-- division_product_sales AS dps
-- JOIN
-- monthly_sales AS ms
-- ON
-- dps.month = ms.month
-- JOIN
-- product_catalog AS pc
-- ON
-- dps.product_id = pc.product_id
-- WHERE
-- ms.type_of_product = 'High_Margin' -- Assumes the name of the column is 'margin_category'
-- ORDER BY
-- ms.month, dps.product_type ;
SELECT
d.product_type,
d.product_id,
d.units_sold,
m.month
FROM
division_product_sales d
JOIN
monthly_sales m ON m.month = d.month
WHERE
d.product_type IN ('Jeans', 'Tshirt', 'Trousers', 'Innerwear') -- assuming these are high-margin categories
AND
m.type_of_product = 'High_Margin'
ORDER BY
d.month, d.product_type;
Learning course: Database management systems
Problem Link: Project - JOIN and Filtering in Database management systems