Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
690 B
1
Indexable
Never
SELECT CASE EXTRACT(MONTH
                    FROM order_date)
           WHEN 1 THEN 'январь'
           WHEN 2 THEN 'февраль'
           WHEN 3 THEN 'март'
           WHEN 4 THEN 'апрель'
           WHEN 5 THEN 'май'
           WHEN 6 THEN 'июнь'
           WHEN 7 THEN 'июль'
           WHEN 8 THEN 'август'
           WHEN 9 THEN 'сентябрь'
           WHEN 10 THEN 'октябрь'
           WHEN 11 THEN 'ноябрь'
           WHEN 12 THEN 'декабрь'
       END AS month,
       ROUND(SUM(subtotal), 2) AS total
FROM adventure.purchase_order_header
WHERE EXTRACT(YEAR FROM order_date) = 2012
GROUP BY month
ORDER BY total DESC;
Leave a Comment