← Practice

New accounts: 1+ transactions in 30 days, Feb–Mar 2025

Level: MiddleTopic: Dates and time series100 XP

Instructions

Consider accounts whose opened_at is on or after February 1, 2025 and strictly before April 1, 2025. For an account, count transactions whose tx_time is strictly before the start of the day opened_at + 30 days (there are no transactions before opened_at in the data, so these are the first 30 days of the account's life). An account is "active" if it has at least 1 such transactions. For each account type (accounts.type) output type, accounts_cnt, the number of considered accounts, active_cnt, the number of active ones, and active_pct, the share of active accounts as a percentage, rounded to 1 decimal place. Sort by type 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