forked from Code-the-Dream-School/Backend-sqlintro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.txt
More file actions
35 lines (28 loc) · 1.55 KB
/
sql.txt
File metadata and controls
35 lines (28 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(1) Using the Customer Table, select the CustomerName, ContactName, and Country. Use ORDER BY to order by Country.
Use LIMIT and OFFSET to get entries 11 through 20. Paste your SQL statement below.
SELECT CustomerName, ContactName, Country FROM Customers
ORDER BY Country
LIMIT 10 OFFSET 10;
(2) Select all columns from the Customer table where the ContactName starts with A. Paste your SQL statement below.
SELECT CustomerName, ContactName, Country FROM Customers
ORDER BY ContactName
LIMIT 10;
(3) Select all columns from the OrderDetails table where the ProductID is 51 and the quantity is greater than 10.
Paste your SQL statement below.
SELECT * FROM OrderDetails
WHERE ProductID = 51 and Quantity > 10;
(4) Insert 3 rows into the Products table. Note that you will have to specify a valid SupplierID and CategoryID,
corresponding to rows from the Supplier and Category tables. Paste your three SQL statements below.
INSERT INTO Products(ProductID, ProductName, SupplierID, CategoryID, Unit, Price) VALUES
(79, "Kimchi", 16, 12, "33 kilos", 45),
(80, "Bagels", 17, 13, "35 kilos", 46),
(81, "Sausage", 18, 14, "12 kilos", 47);
(5) Update the two top rows of the Products Table to increase the price by 1.50. (Get SQL to do the addition for you.) Paste your SQL statement below.
Update Products set Price = Price + 1.5 WHERE ProductID IN(
SELECT ProductID
FROM Products
order by ProductID asc
LIMIT 2);
(6) Delete all rows of the Products Table where the price is less than 7.00. Paste your SQL statement below.
DELETE FROM Products
WHERE Price < 7.00;