Search ⌘K
Alibaba
Alibaba

Foundations Track · Medium · 25 min

07. Compressed Mode [Alibaba Interview]

/*Level: MEDIUM You are trying to find the most common (aka the mode) number of items bought per order on Alibaba. However, instead of doing analytics on all...

Foundations Track
Medium
25 min
filtering
aggregation

Company labels are directional practice context, not official interview guidance.

Timer 00:00
Back to practice

Objective

Practice filtering through a Alibaba-tagged business scenario.

Approach

Use this track to lock in clean query structure, basic filtering logic, and confidence with grouped output.

Company context

Company labels are directional practice context, not official interview guidance.

Prereq: query basics
Prereq: filtering

/*Level: MEDIUM You are trying to find the most common (aka the mode) number of items bought per order on Alibaba. However, instead of doing analytics on all Alibaba orders, you have access to a summary table, which describes how many items were in an order (item_count), and the number of orders that had that many items (order_occurrences). In case of multiple item counts, display the item_counts in ascending order. items_per_order Table: Column_Name Type item_count integer order_occurrences integer items_per_order Example Input: item_count order_occurrences 1 500 2 1000 3 800 4 1000 My solution:*/ SELECT item_count as mode FROM items_per_order WHERE order_occurrences = (SELECT MAX(order_occurrences) FROM items_per_order) ORDER BY item_count

Pro question
This is a Pro question

Upgrade to Pro to unlock this prompt, the SQL workspace, and all 254 problems.

Upgrade to Pro — unlock all 254 problems
Editor
SQL workspace

Run queries against the protected question data, then submit once the result shape looks right.

Sign in to run SQL

Create a free account or sign in before running queries against protected question data.