Order Items Average
Beginner Mode
Objective
Write a SQL query to calculate the average number of items per order.
Table Schema:
- items_per_order
| Column | Type | Description |
|---|---|---|
| item_count | INTEGER | Number of items in an order |
| order_occurrences | INTEGER | Number of orders with that item count |
Task Requirements:
- Calculate the weighted mean of items per order
- Account for the frequency of each item count
- Round the result to 1 decimal place
Output columns: mean_items
Examples
Example 1:
Output:
Input:
| items_per_order | |
|---|---|
| item_count | order_occurrences |
| 1 | 500 |
| 2 | 1000 |
| 3 | 800 |
| 4 | 1000 |
| mean_items |
|---|
| 2.7 |
Code Environment
Sign in or try as guest to run your code.
Track
| Question | Difficulty | Company | Access |
|---|
Need more practice in this area? Explore more questions →
Amazon