← Dates and time series

Account 41 activity, 9 mo. from March 1, 2025

Level: Middle100 XP

Instructions

Build a series of 9 consecutive months: from the month starting on March 1, 2025 to the month starting on November 1, 2025, inclusive. For the account with id = 41 (transactions.account_id) output for each month: month, the first day of the month (type date), tx_cnt, the number of transactions with tx_time in that month, income, the sum of positive amount values (inflows), and spent, the sum of negative amount values taken as a positive number (spending). Months without transactions must still be output with zeros in all three columns. Sort by month ascending.

Hints

Each next one is more detailed and costs more

Log in to open hints

Query

Result

Click Run to see the query result, or Check to submit your solution.

Dataset schema

accounts.client_id (0…N) ↔ clients.id (1…1)transactions.account_id (0…N) ↔ accounts.id (1…1)accountsPKidintegerFKclient_idintegerclientsPKidintegertransactionsPKidintegerFKaccount_idinteger
Exactly oneZero or oneZero or more
Table relationships
  • N:1Many-to-oneaccounts.client_id → clients.id
  • N:1Many-to-onetransactions.account_id → accounts.id

Table data

PostgreSQL

Select a table in the diagram or list to view its rows.

Dataset schema