Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Table: orders

+--------------+---------+
| Column Name  | Type    |
+--------------+---------+
| order_id     | int     |
| customer_id  | int     |
| restaurant_id| int     |
| order_date   | date    |
| order_amount | float   |
+--------------+---------+

order_id is the primary key. Each row represents one order placed by a customer.

For each month, compute the percentage of active customers who placed more than 30 orders in that month. An active customer is any customer with at least one order in that month. High-frequency customers are those with more than 30 orders in the same month.

Output: month (YYYY-MM), active_customers, high_freq_customers, pct_high_freq (rounded to 2 decimals, on a 0–100 scale). The result is sorted by month ascending.

The result format is shown below.

Example

Input:

orders table (abbreviated):
+----------+-------------+---------------+------------+--------------+
| order_id | customer_id | restaurant_id | order_date | order_amount |
+----------+-------------+---------------+------------+--------------+
| 1..35    | 1           | 10            | 2021-01-01 | 10.0         |  (35 orders)
| 36..55   | 2           | 10            | 2021-01-01 | 10.0         |  (20 orders)
| 56..65   | 3           | 10            | 2021-01-01 | 10.0         |  (10 orders)
| 66..105  | 4           | 10            | 2021-02-01 | 10.0         |  (40 orders)
| 106..110 | 5           | 10            | 2021-02-01 | 10.0         |  (5 orders)
+----------+-------------+---------------+------------+--------------+

Output:

+---------+-----------------+--------------------+--------------+
| month   | active_customers| high_freq_customers| pct_high_freq|
+---------+-----------------+--------------------+--------------+
| 2021-01 | 3               | 1                  | 33.33        |
| 2021-02 | 2               | 1                  | 50.0         |
+---------+-----------------+--------------------+--------------+

Explanation:
In January, 3 customers were active and 1 (C1 with 35 orders) exceeded 30, giving 1/3 * 100 = 33.33%. In February, 2 customers were active and 1 (C4 with 40 orders) exceeded 30, giving 50.0%.


Accepted
25/104
Acceptance Rate24.0%
Test Cases
Input
-
Output
-
Expected
-