Sobes.tech
Junior — Senior

10 clients with the most items in their cart

livecode

Task condition

There are two tables in the database: public.customer and public.carts. It is necessary to obtain a list of ten customers (columns: id, email) with the highest total number of items in their carts (considering the amount field).

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 |
+--------+--------+----------+