Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fikretellek
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

@sayoiscool sayoiscool left a 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%';

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%';

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;

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'

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.

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.

2 participants