AnalystPath

Weighted Mean Order Size

SQLEasyJunior levelAlibaba~15 min

Problem

**[Asked at Alibaba]**

To save storage, Alibaba's data warehouse stores order-size data in a
**compressed** format: instead of one row per order, there is one row per
distinct item count, along with how many orders had that item count.

Calculate the **average number of items per order** from this compressed table.
Round the result to **1 decimal place**.

Return a single value in a column named `mean_items`.

Tables

Example rows — the live problem includes the full dataset.

order_sizes
size_iditems_countnum_orders

Expected output

Your answer should return 1 row with the columns mean_items.

Starter code (SQL)

SELECT *
FROM order_sizes;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions