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.
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.
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.
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`;