You are on page 1of 1

grou by :

SELECT COUNT(*) AS banyak_custumers,country FROM customers GROUP BY country;

banyak customers negara prancis


SELECT COUNT(*) AS banyak_customers,country FROM customers WHERE country='france';

banyak product di jenis product


SELECT COUNT(*) productCode,productLine FROM products GROUP BY productLine;

banyak customers di kota


SELECT COUNT(*) productCode,productLine FROM products GROUP BY productLine;

banyak status di pesanan


SELECT COUNT(*) AS banyak_pesanan,STATUS FROM orders GROUP BY STATUS;

jumlah banyak di negara


SELECT SUM(creditLimit),country FROM customers GROUP BY country;

SELECT SUM(payments.`amount`)AS jumlah_pembayaran,customers.`country`


FROM customers
INNER JOIN payments
ON customers.`customerNumber`=payments.`customerNumber`
GROUP BY country
ORDER BY SUM(payments.`amount`) DESC;

SELECT COUNT(orders.`orderNumber`),customers.`country`
FROM customers
INNER JOIN orders
ON customers.`customerNumber`=orders.`customerNumber`
GROUP BY country
ORDER BY COUNT(orders.`orderNumber`);

hubungkan tabel emplooyee dan offfice innerjoin


SELECT employees.`firstName`,employees.`lastName`,offices.`country`
FROM employees
INNER JOIN offices
ON employees.`officeCode`=offices.`officeCode`;

nama customer dan status


SELECT customers.`customerName`,orders.`status`
FROM customers
INNER JOIN orders
ON customers.`customerNumber`=orders.`customerNumber`;

menampilkan tabel customers, order dan orderdetail


SELECT customers.`country`,orderdetails.`quantityOrdered`
FROM customers
INNER JOIN orders
ON customers.`customerNumber`=orders.`customerNumber`
INNER JOIN orderdetails
ON orders.`orderNumber`=orderdetails.`orderNumber`;

You might also like