You are on page 1of 1

1.

SELECT year(order_date) AS Tahun, COUNT(order_id) AS Frekuens_Transaksi FROM orders GROUP BY


Tahun;

2. SELECT product_id, SUM((unit_price*quantity-(unit_price*quantity*discount))) as Total_penjualan


FROM order_details group by product_id order BY Total_penjualan DESC;

3. SELECT a.customer_id, SUM((b.unit_price*b.quantity-(b.unit_price*b.quantity*b.discount))) AS


Total_nilai_pesanan FROM orders a LEFT JOIN order_details b ON a.order_id = b.order_id group by
customer_id order by Total_nilai_pesanan desc LIMIT 5;

4. SELECT YEAR(a.order_date) AS Tahun, a.customer_id, SUM((b.unit_price*b.quantity-


(b.unit_price*b.quantity*b.discount))) AS Total_nilai_pesanan FROM orders a LEFT JOIN order_details b
ON a.order_id = b.order_id WHERE year(a.order_date) = '1996' group by customer_id order by
Total_nilai_pesanan desc LIMIT 5;

5. SELECT b.product_id, SUM((b.unit_price*b.quantity-(b.unit_price*b.quantity*b.discount))) AS


Total_nilai_pesanan FROM orders a LEFT JOIN order_details b ON a.order_id = b.order_id WHERE
a.customer_id = 'QUICK'GROUP BY product_id ORDER BY Total_nilai_pesanan desc;

You might also like