Skip to content
Spinner
DataFrameas
revenue_by_product_line
variable
SELECT product_line, 
       CASE WHEN EXTRACT(month FROM date) = 6 THEN 'June'
            WHEN EXTRACT(month FROM date) = 7 THEN 'July'
            WHEN EXTRACT(month FROM date) = 8 THEN 'August'
       END AS month,
       warehouse,
       ROUND(SUM(total::numeric)*(1 - AVG(payment_fee)::numeric), 2) AS net_revenue
FROM sales
WHERE client_type = 'Wholesale'
GROUP BY product_line, warehouse, EXTRACT(month FROM date)
ORDER BY product_line, month, net_revenue DESC