Какой счёт клиенты открывают первым, вторым, третьим
Questions like this come up in interviews at Сбер
Level: MiddleTopic: Window functions100 XP
Instructions
Пронумеруйте счета каждого клиента по порядку открытия: по opened_at, при равенстве — по id (первый открытый счёт получает номер 1). Постройте сводку по типу счёта (type): as_first — у скольких клиентов счёт этого типа стоит под номером 1, as_second — под номером 2, as_third — под номером 3. Выведите type, as_first, as_second, as_third. Порядок строк не важен.
not translated yetHints
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.