← Practice

Spending 13:00–17:00, all days, May–Jun 2025

Level: JuniorTopic: Dates and time series50 XP

Instructions

Consider debits (transactions.amount < 0) whose tx_time is on or after May 1, 2025 and strictly before July 1, 2025, made on any days and in the hours from 13 to 16 inclusive (the hour is taken from tx_time: for example, 12 is the interval from 12:00:00 to 12:59:59). Group by category and output category, tx_cnt, the number of debits, total_spent, the total of the debits as a positive number (minus the sum of amount), and avg_check, the average debit size as a positive number, rounded to 2 decimal places. Row order does not matter.

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