Skip to content

Conversation

@fhkahin
Copy link

@fhkahin fhkahin commented May 17, 2024

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.

@sonarqubecloud
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

@fhkahin fhkahin changed the title Read me updated, All queries are written in SQL NW6 | Fathi Kahin | Module-DataBases | Big_Spender | week 2 May 17, 2024
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.

Good work overall and good understanding of queries, however there's opportunity to master more postgresql operators.


```sql
INSERT YOUR QUERY HERE
SELECT amount

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

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

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)

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

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);

Copy link

@sayoiscool sayoiscool Jun 15, 2024

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?

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