Sobes.tech
Junior — Senior
51

10 клиентов с наибольшим числом товаров в корзине

Компании, где спрашивали:

Lamoda Tech
Условие задачи

В базе присутствуют две таблицы public.customer и public.carts. Необходимо получить список из десяти клиентов (столбцы: id, email), у которых суммарное количество товаров в корзине (учитывая поле amount) максимально.

Table "public.carts"
+-------------+-----------------------------+-------------------------+
| Column      | Type                        | Modifiers               |
+-------------+-----------------------------+-------------------------+
| sku         | bigint                      | not null                |
| country     | country_enum                | not null                |
| customer_id | bigint                      | not null                |
| amount      | bigint                      | not null                |
| updated_at  | timestamp without time zone | default now() not null |
+-------------+-----------------------------+-------------------------+

Table "public.customer"
+--------+--------+----------+
| Column | Type   | Modifiers |
+--------+--------+----------+
| id     | bigint | not null |
| email  | text   | not null |
+--------+--------+----------+