Clients aged 51–60 on January 31, 2025: Москва
Level: JuniorTopic: Dates and time series50 XP
Instructions
A client's age on January 31, 2025 is the number of full years between birth_date and that date (age(January 31, 2025, birth_date), years only). Consider clients from the city 'Москва' (clients.city) whose age on that date is from 51 to 60 years inclusive. Group them by segment (clients.segment) and output segment, clients_cnt, the number of clients, and avg_age, the average age on that date, rounded to 1 decimal place. Do not output segments without matching clients. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Exactly oneZero or oneZero or more
Table relationships
- N:1Many-to-one
accounts.→client_id clients.id - N:1Many-to-one
transactions.→account_id accounts.id
Table data
PostgreSQL
Select a table in the diagram or list to view its rows.