-
-
Notifications
You must be signed in to change notification settings - Fork 103
NW6 | Sabella Fisseha | Module-DataBases | Big_Spender | week 2 #159
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
|
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 work overall! Good attention to detail with the table insertions and good understanding of some postgresql operators. However a few more query revisions needed, as described in comments.
``` | ||
|
||
```` | ||
select * from spends where description ilike '%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 capitalisations into consideration with 'ilike'. note you don't have to mix cases in the word, e.g '%FeE%' can simply be written as '%fee%'. ILIKE already handles the case insensitive matching
|
||
SELECT spends.*, expense_areas.expense_area | ||
FROM spends | ||
INNER JOIN expense_areas ON expense_areas.id = spends.expense_area_id |
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 |
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
|
||
SELECT SUM(spends.amount) AS total_amount | ||
FROM spends | ||
INNER JOIN suppliers ON suppliers.id = spends.supplier_id |
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 job with the joins! However, two columns are expected in the results. What additional information from the suppliers table should be included in the SELECT statement?
|
||
SELECT date, SUM(amount) AS total_amount | ||
FROM spends | ||
WHERE date BETWEEN '2021-03-01' AND '2021-04-01' |
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. Note that total amounts for only those two dates are required, and not every date inbetween. Which operator will allow for multiple distinct values to be specified in your WHERE statement?
insert into expense_types (expense_type) values ('Hardware'); | ||
select id from expense_areas where expense_area = 'IT'; | ||
insert into expense_areas (expense_area) values ('IT'); | ||
|
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.