0% found this document useful (0 votes)
32 views1 page

Kode Pertemuan 12

This document contains several SQL queries that group, filter, and join data from tables in a database. The queries count or sum values and group the results by fields like country, product line, order status, and more. They also join tables like customers and orders, employees and offices to retrieve related data.

Uploaded by

Irawati 18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views1 page

Kode Pertemuan 12

This document contains several SQL queries that group, filter, and join data from tables in a database. The queries count or sum values and group the results by fields like country, product line, order status, and more. They also join tables like customers and orders, employees and offices to retrieve related data.

Uploaded by

Irawati 18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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