Untitled

mail@pastecode.io avatar
unknown
sql
2 months ago
477 B
0
Indexable
Never
SELECT
    quarter,
    SUM(quantity) AS total_penjualan,
    SUM(quantity * priceEach) AS revenue
FROM (
    SELECT
        orderNumber,
        status,
        quantity,
        priceEach,
        '1' AS quarter
    FROM
        orders_1
    UNION ALL
    SELECT
        orderNumber,
        status,
        quantity,
        priceEach,
        '2' AS quarter
    FROM
        orders_2
) AS tabel_a
WHERE
    status = 'Shipped'
GROUP BY
    quarter;
Leave a Comment