The document contains 5 SQL queries that analyze order data from a database. The first query counts the number of orders grouped by year. The second query sums the total sales amount grouped by product. The third query sums the total order value for each customer. The fourth query limits the third query to orders from 1996. The fifth query sums the total order value for products ordered by the customer "QUICK".
The document contains 5 SQL queries that analyze order data from a database. The first query counts the number of orders grouped by year. The second query sums the total sales amount grouped by product. The third query sums the total order value for each customer. The fourth query limits the third query to orders from 1996. The fifth query sums the total order value for products ordered by the customer "QUICK".
The document contains 5 SQL queries that analyze order data from a database. The first query counts the number of orders grouped by year. The second query sums the total sales amount grouped by product. The third query sums the total order value for each customer. The fourth query limits the third query to orders from 1996. The fifth query sums the total order value for products ordered by the customer "QUICK".
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;