-
-
Notifications
You must be signed in to change notification settings - Fork 103
NW6 | Fathi Kahin | Module-DataBases | Big_Spender | week 2 #160
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
base: main
Are you sure you want to change the base?
Conversation
|
sayoiscool
left a comment
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 overall and good understanding of queries, however there's opportunity to master more postgresql operators.
|
|
||
| ```sql | ||
| INSERT YOUR QUERY HERE | ||
| SELECT amount |
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.
Almost there! Requirement is to find out the transactions between 30,000 and 31,000, not just the amount. How will your select statement be amended to get the desired result?
| INSERT YOUR QUERY HERE | ||
| SELECT * | ||
| FROM spends | ||
| WHERE 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 approach and query is on the right track. However, based on the scenario question, "fee" might be inconsistently capitalised in the data. To avoid missing results, the WHERE clause should account for this. What postgresql operator allows for case insensitive matching? Compare your results
| SELECT sp.date, sp.description, expense.expense_area | ||
| FROM spends sp | ||
| JOIN expense_areas expense ON (sp.expense_area_id = expense.id) | ||
| WHERE expense.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!
|
|
||
| ```sql | ||
| INSERT YOUR QUERY HERE | ||
| SELECT to_char(date,'YYYY-MM') AS month, sum(amount) |
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 job with the date formatting. well done
|
|
||
| ```sql | ||
| INSERT YOUR QUERY HERE | ||
| SELECT sp.amount, sup.supplier |
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.
The question is for the total amount spent by each supplier. Which operator missing here is needed to get the desired result?
| INSERT YOUR QUERIES HERE | ||
| INSERT INTO spends (expense_type_id, expense_area_id, supplier_id, date, transaction_no, supplier_inv_no, description, amount) | ||
| VALUES (7, 18, 16, '2021-08-19', 38104091, '3780119655', 'Computer Hardware Dell', 32000); | ||
|
|
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 attempt here. The rows ' Dell', 'Hardware' and 'IT' are missing from other tables, what extra step is needed to have the rows populated where necessary? What effect will this change have on the 'id's inserted in spends table?




Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.