Skip to content

Instantly share code, notes, and snippets.

@bl4ckck
Last active April 13, 2022 23:07
Show Gist options
  • Save bl4ckck/e7949b8196a75382d24061226eed111c to your computer and use it in GitHub Desktop.
Save bl4ckck/e7949b8196a75382d24061226eed111c to your computer and use it in GitHub Desktop.
Alvin Naufal: Assignment SQL Query Part 1
/**
* Alvin Naufal
*/
-- 1. Tampilkan Employees yang memiliki FirstName berinisial huruf 'A'
SELECT * FROM Employees WHERE FirstName LIKE 'A%';
-- 2. Tampilkan jumlah Employees yang memiliki panjang LastName lebih dari 5 huruf
SELECT COUNT(EmployeeID) AS TotalEmployee FROM Employees WHERE LENGTH(LastName) > 5;
-- 3. Tampilkan customerName yang berasal dari negara Mexico
SELECT CustomerName FROM Customers WHERE Country = 'Mexico';
-- 4. Tampilkan total price untuk product yang memiliki kategori Seafood
SELECT SUM(P.Price) AS TotalPrice FROM Products P
JOIN Categories C
ON P.CategoryID = C.CategoryID
WHERE C.CategoryName = 'Seafood';
-- 5. Tampilkan average price untuk supplier yang berasal dari negara Jepang
SELECT AVG(P.Price) AS AveragePrice FROM Products P
JOIN Suppliers S
ON P.SupplierID = S.SupplierID
WHERE S.Country = 'Japan';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment