Skip to content

this is my lesson 1 assignment#1

Open
myang1010 wants to merge 1 commit intomasterfrom
sql-lesson
Open

this is my lesson 1 assignment#1
myang1010 wants to merge 1 commit intomasterfrom
sql-lesson

Conversation

@myang1010
Copy link
Owner

complete lesson 1 work

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.

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.

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; No newline at end of file

Choose a reason for hiding this comment

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

Well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants