-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NW6 | Fikret Ellek | Module-DataBases | [TECH ED] Big Spender | week 2 #161
base: main
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work overall. Well done
@@ -68,39 +68,39 @@ INSERT YOUR QUERY HERE | |||
**You:** Then here's the query for that: | |||
|
|||
```sql | |||
INSERT YOUR QUERY HERE | |||
SELECT * FROM spends WHERE LOWER(description) LIKE '%fee%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work taking the capitlisations into consideration with 'LOWER'
``` | ||
|
||
**Farnoosh:** Hi, it's me again. It turns out we also need the transactions that have the expense area of 'Better Hospital Food'. Can you help us with that one? | ||
|
||
**You:** No worries. Here's the query for that: | ||
|
||
```sql | ||
INSERT YOUR QUERY HERE | ||
SELECT s.*, e.expense_area FROM spends s JOIN expense_areas e ON s.expense_area_id=e.id WHERE LOWER(e.expense_area) LIKE '%better hospital food%'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of joins!
``` | ||
|
||
**Claire:** Great, that's very helpful. How about the total amount spent for each month? | ||
|
||
**You:** You can get that by using the GROUP BY clause. Here's the query: | ||
|
||
```sql | ||
CREATE YOUR QUERY HERE | ||
SELECT DATE_TRUNC('month', date)::DATE AS month, SUM(amount) AS total_amount FROM spends GROUP BY month ORDER BY month; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work with the date format in your select statement!
INSERT INTO expense_types (expense_type) | ||
SELECT 'Hardware' | ||
WHERE NOT EXISTS ( | ||
SELECT 1 FROM expense_types WHERE expense_type = 'Hardware' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great attention to detail! The 'Hardware', 'Dell', and 'IT' rows were missing from the other tables, and you've done well by adding the necessary insert statements to populate them.
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.