Y9 SQL PRACTICE: QUESTIONS
1.- List column Unit of the database Products
2.- List columns Address, City and Phone of the database Suppliers
3.- List only the different values of the countries of the database Customers
4.- List the all the columns of the CustomerID number 34 of the database Orders
5.- List the column OrderID of the EmployeeID number 4 of the database Orders
6.- List all the columns of the database Products with SupplierID number 1 and CategoryID number 1
7.- List all the columns of the database Orders with EmployeeID number 3 or ShipperID number 1
8.- List the column ProductName of the database Products without SupplierID number 1
9.- List the columns ProductName and Price of the database Products sort by the price
10.- How many records has the database Suppliers?
11.- How many records has the database Customers if Germany is the country?
12.- Make the sum of total Price at the database Products
13.- Calculates the average Price at the database Products about the Supplier number 1
STATEMENTS
SELECT column1 , column2 , ... FROM table_name ;
SELECT DISTINCT column1 , column2 , ... FROM table_name ;
SELECT column1 , column2 , ... FROM table_name WHERE condition;
SELECT column1, column2... FROM table_name WHERE condition1 AND condition2...;
SELECT column1, column2... FROM table_name WHERE condition1 OR condition2...;
SELECT column1, column2... FROM table_name WHERE NOT condition ;
SELECT * FROM Products ORDER BY Price;
SELECT COUNT (column_name) FROM table_name WHERE condition ;
SELECT SUM (column_name) FROM table_name WHERE condition ;
SELECT AVG (column_name) FROM table_name WHERE condition ;
SQL PRACTICE: ANSWERS
1.- SELECT Unit FROM Products;
2.- SELECT Address, City, Phone FROM Suppliers;
3.- SELECT DISTINCT Country FROM Customers;
4.- SELECT * FROM Orders WHERE CustomerID=34;
5.- SELECT OrderID FROM Orders WHERE EmployeeID=4;
6.- SELECT * FROM Products WHERE SupplierID=1 AND CategoryID=1;
7.- SELECT * FROM Orders WHERE EmployeeID=3 OR ShipperID=1;
8.- SELECT ProductName FROM Products WHERE NOT SupplierID=1;
9.- SELECT ProductName, Price FROM Products ORDER BY Price;
10.- SELECT COUNT(*) FROM Suppliers;
11.- SELECT COUNT(*) FROM Customers WHERE Country="Germany";
12.- SELECT SUM(Price) FROM Products;
13.- SELECT AVG(Price) FROM Products WHERE SupplierID = 1;