Skip to content

Lesson2#1

Open
five-starrr wants to merge 2 commits intomainfrom
lesson2
Open

Lesson2#1
five-starrr wants to merge 2 commits intomainfrom
lesson2

Conversation

@five-starrr
Copy link
Owner

No description provided.

Copy link

@gacurl gacurl left a comment

Choose a reason for hiding this comment

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

comments available - nicely done here.

1. Use an SQL SELECT statement to retrieve the first 10 rows of the Customer table, ordered by CustomerName.
Paste your SQL statement below:
- SELECT * FROM Products LIMIT 10;

Copy link

Choose a reason for hiding this comment

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

this query retrieves the first 120 rows of the Products table.
since you need the first 10 rows of the Customer Table ordered by Customer Name, please resubmit with accurate query.
Retrieve from the Customers table and order by CustomerName.

- SELECT ProductName, Price
FROM Products
WHERE Price < 20;

Copy link

Choose a reason for hiding this comment

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

noice!

- SELECT *
FROM Employees
WHERE LastName LIKE "C%";

Copy link

Choose a reason for hiding this comment

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

nolce!

INNER JOIN Customers
ON Orders.CustomerID = Customers.CustomerID
WHERE CustomerName LIKE "A%";

Copy link

Choose a reason for hiding this comment

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

correct! As you grow into your SQL skills, consider better readability. You're likely gonna come back to your code in the future and then try to remember what you want/ed the code to do.
as an improvement (READ: the code works - this is only a thought to improve)
1 - Use table aliases (o for Orders and c for Customers) for better readability, and
2 - make sure to use SINGLE quotes for string literals in SQL.

below:
SELECT o.OrderID, c.CustomerName
FROM Orders o
INNER JOIN Customers c ON o.CustomerID = c.CustomerID
WHERE c.CustomerName LIKE 'A%';

ON c.CustomerID = o.CustomerID
ORDER BY CustomerName ASC;


Copy link

Choose a reason for hiding this comment

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

you'll need to specify the query based on the alias you set.
Order by c.CustomerName to specify the alias.





Copy link

Choose a reason for hiding this comment

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

minor hit here with the date formatting - welcome to coding where dates are almost as frustrating as getting a printer/copier to work!
please update OrderDate to the standard SQL date format 'YYYY-MM-DD'

VALUES (10333, 5, 20), (10444, 6, 20), (10284, 3, 5);



Copy link

Choose a reason for hiding this comment

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

nice - but the order number should remain consistent - you need the same order number.

- DELETE FROM OrderDetails WHERE OrderDetailID = 521;



Copy link

Choose a reason for hiding this comment

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

noice

WHERE Price < 20;



Copy link

Choose a reason for hiding this comment

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

noice


- DELETE FROM Orders WHERE CustomerID = 76;
DELETE FROM Customers WHERE CustomerID = 76;

Copy link

Choose a reason for hiding this comment

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

YES! Nicely done here!

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.

3 participants