Skip to content

this is my lesson 1 assignment#1

Open
myang1010 wants to merge 1 commit into
masterfrom
sql-lesson
Open

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

Conversation

@myang1010
Copy link
Copy Markdown
Owner

complete lesson 1 work

Comment thread sql.txt
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done.

Comment thread sql.txt
(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%";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perfectly done.

Comment thread sql.txt
Paste your SQL statement below.

SELECT * FROM OrderDetails WHERE ProductID = 51 AND quantity > 10;

Copy link
Copy Markdown

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.

Comment thread sql.txt
INSERT INTO Products (SupplierID, CategoryID) VALUES (1, 3);
INSERT INTO Products (SupplierID, CategoryID) VALUES (2, 1);
INSERT INTO Products (SupplierID, CategoryID) VALUES (2, 4);

Copy link
Copy Markdown

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

Comment thread sql.txt
(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);

Copy link
Copy Markdown

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.

Comment thread sql.txt

(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
Copy link
Copy Markdown

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