Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sql.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
(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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done.

(2) Select all columns from the Customer table where the ContactName starts with A. Paste your SQL statement below.

SELECT * FROM Customers WHERE ContactName LIKE "A%";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfectly done.

(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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, exactly how I would have done it.

(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 (SupplierID, CategoryID) VALUES (1, 3);
INSERT INTO Products (SupplierID, CategoryID) VALUES (2, 1);
INSERT INTO Products (SupplierID, CategoryID) VALUES (2, 4);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works. You could also have done something like below:
INSERT INTO Products
VALUES
(NULL, "Hot Chesse", 1, 1, "1 kg pkg", 30.85),
(NULL, "Nachos", 1, 1, "2kg pkg", 60.55),
(NULL, "Taco Tortilla", 1, 1, "5 kg pkg", 200);

(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.50 WHERE ProductID IN ( SELECT ProductID from Products LIMIT 2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works. In this case your where condition could be simplified to WHERE ProductID IN (1, 2). However, the way you did it does show how subqueries can be used.

(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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done.