Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

MANCHESTER -CLASS-5-Miguel-Cabral-SQL-Coursework-WEEK-2#189

Open
Miguel-Cabral wants to merge 4 commits intoCodeYourFuture:mainfrom
Miguel-Cabral:main
Open

MANCHESTER -CLASS-5-Miguel-Cabral-SQL-Coursework-WEEK-2#189
Miguel-Cabral wants to merge 4 commits intoCodeYourFuture:mainfrom
Miguel-Cabral:main

Conversation

@Miguel-Cabral
Copy link
Copy Markdown

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name:
  • Your City:
  • Your Slack Name:

Homework Details

  • Module:
  • Week:

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Comment thread 2-exercises/task.md
2. Retrieve all the customers in ascending name sequence
A = SELECT * FROM customers ORDER BY name ASC;
3. Retrieve all the products whose name contains the word `socks`
A = SELECT * FROM products WHERE lower(product_name) LIKE '%socks%';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Excellent that you've made the casing match on both sides, and correctly used LIKE with wildcards % at each end

Comment thread 2-exercises/task.md
ON product_availability.supp_id = suppliers.id AND suppliers.country = 'United Kingdom';

8. Retrieve all orders, including order items, from customer ID `1`. Include order id, reference, date and total cost (calculated as quantity * unit price).
A = SELECT orders.id, orders.order_reference, orders.order_date, order_items.quantity * product_availability.unit_price AS total_cost
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Putting an explicit name for the calculated column as total_cost is good!

You've split the rest of the query on to one line per clause, which makes this easy to read. Sometimes it's good to split each field in the select clause into a separate line as well so I can quickly see exactly what fields are returned, without my eyes need to scan past commas.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants