Skip to content

Conversation

@SalehOmar-Y
Copy link

@SalehOmar-Y SalehOmar-Y commented Dec 14, 2025

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Added SQL queries to satisfy all defined user stories

Questions

Ask any questions you have for your reviewer.

@SalehOmar-Y SalehOmar-Y changed the title WM | Cohort | Saleh Yousef| Sprint 2| Big Spender WM | Nov-25 | Saleh Yousef| Sprint 2| Big Spender Dec 14, 2025
@SalehOmar-Y SalehOmar-Y changed the title WM | Nov-25 | Saleh Yousef| Sprint 2| Big Spender WM | N\A | Saleh Yousef| Sprint 2| Big Spender Dec 14, 2025
```sql
INSERT YOUR QUERY HERE
Select * from spends
Where transaction_no Between 30000 And 31000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite correct here - at the moment when i run this query I get a empty table, but I should be seeing all transactions that spent ammounts between £30,000 and £31,000 - have a look again at this query.

Comment on lines 80 to 85
Select transaction_no, expense_area
from spends
Join expense_areas
On spends.expense_area_id = expense_areas.id
Where expense_area ILIKE 'Better Hospital Food';
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure about your choice to not include any other information except transaction_no and expense_area, as an output it's very uninformative. Especially as the key information will be amounts spent, suppliers, dates etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My initial understating was that the requirements were transactions number and the expense area of 'Better Hospital Food'. Now the query shows all the other information needed from the tables.


```sql
CREATE YOUR QUERY HERE
Select DATE_TRUNC('month', spends.date) AS month

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could approach this query with the mindset of "I am only going to give information that is informative to this request".

In this case, simply knowing the month alone is what the finance person is requesting.

So how could you turn the output of a timestamp rounded to a month into a column of just data identifying which month it is. No specific dates, no timestamps, just a month.


```sql
INSERT YOUR QUERY HERE
Select description, SUM(amount) AS total_spent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We aren't looking for "description" here. In the database you can see a suppliers table which is joined to the spends table via the supplier_id.

How can you use this relationship to pull in the supplier name instead of the "description" of the charge?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description column replaced by amount column so the information need are accessible now.

Copy link

@Poonam-raj Poonam-raj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some strong psql queries being built here. A nice use of the built-in functions psql offers us to make our queries efficient. Particular love the final query to find ids for the expense type and area.

There are a few moments in the query where output isn't what we're looking for or the output could be refined so the information in the table is informative and usable for the user. Take a look at those queries and let me know how it goes when you rework them.

@SalehOmar-Y SalehOmar-Y changed the title WM | N\A | Saleh Yousef| Sprint 2| Big Spender WM | N/A | Saleh Yousef| Sprint 2| Big Spender Jan 5, 2026
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