0% found this document useful (0 votes)
7 views10 pages

SQL Part

The document contains a series of SQL queries demonstrating various commands such as SELECT, COUNT, SUM, and UNION across different tables like sales, products, staff, and customer. It showcases the use of conditions like BETWEEN, ORDER BY, NOT, LIKE, and IN to filter and organize data. Each query serves a specific purpose, such as retrieving data, calculating totals, or combining results from multiple tables.

Uploaded by

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

SQL Part

The document contains a series of SQL queries demonstrating various commands such as SELECT, COUNT, SUM, and UNION across different tables like sales, products, staff, and customer. It showcases the use of conditions like BETWEEN, ORDER BY, NOT, LIKE, and IN to filter and organize data. Each query serves a specific purpose, such as retrieving data, calculating totals, or combining results from multiple tables.

Uploaded by

nurinjazlina4408
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

1.

SQL BETWEEN – sales

SELECT * FROM sales WHERE SaleDate BETWEEN '2023-06-15' AND '2023-06-20';

2. SQL ORDER BY – PRODUCT

SELECT * FROM products ORDER BY Price DESC;


3. SQL NOT – STAFF ID

SELECT * FROM staff WHERE NOT StaffID > 50;

4. SQL LIKE – STAFF

SELECT * FROM customer WHERE Name LIKE '%g';


5. SQL WHERE – PRODUCTS

SELECT * FROM products WHERE Price <55;

6. SQL COUNT – PRODUCTS

SELECT COUNT(ProductID) FROM products WHERE Price > 20;


7. SQL BETWEEN – CUSTOMER

SELECT 'customer' AS Type, Name, ContactNumber, Email FROM customer UNION SELECT
'supplier', Name, ContactNumber, Email FROM supplier;

8. SQL UNION – CUSTOMER

SELECT *FROM customer WHERE State = 'Kedah' AND Name LIKE 'k%';
9. SQL and – CUSTOMER

SELECT * FROM customer WHERE State = 'Perak' OR State = 'Selangor';

10. SQL SUM – PRODUCTS

SELECT SUM(StockQuantity) FROM products


11. SQL COUNT – STAFF

SELECT COUNT(StaffID), Position FROM staff GROUP BY Position HAVING COUNT(StaffID) > 5;

12. SQL IN – STAFF

SELECT * FROM staff WHERE Status IN ('Active');


13. SQL UNION – SUPPLIER

SELECT SupplierID, Name, ContactNumber, Email, State FROM supplier WHERE EXISTS
( SELECT 1 FROM products WHERE products.SupplierID = supplier.SupplierID AND Price <
20);

14. SQL BETWEEN – PRICE

SELECT AVG(Price) FROM products;


15. SQL BETWEEN – SUPPLIER

SELECT ProductID, Name, Price, StockQuantity, SupplierID, Category


FROM Products WHERE Category = ANY ( SELECT Category FROM
Products WHERE StockQuantity > 50 );

16. SQL MIN – PRODUCTS

SELECT MIN(TotalAmount) FROM sales;


17. SQL MAX – PRODUCT

SELECT MAX(TotalAmount) FROM sales;

You might also like