Premium problem60. Monthly Top Seller

Medium Locked

orders(order_id, seller_id, gross_merchandise_value, ordered_at)

For every month of 2026 that has orders, return the seller or sellers with the highest total GMV. When two sellers tie for first, return both.

Return month as 'YYYY-MM', seller_id and gmv, ordered by month then seller_id.

ROW_NUMBER would pick one of the tied sellers arbitrarily and silently drop the other, so the ranking function matters here.

Tables

orders

order_id  seller_id  gross_merchandise_value  ordered_at
--------  ---------  -----------------------  ----------
1         1          500.00                   2026-01-05
2         2          300.00                   2026-01-06
3         2          400.00                   2026-01-07
4         1          300.00                   2026-02-01
5         3          300.00                   2026-02-02
6         2          100.00                   2026-02-03
7         9          10.00                    2025-12-31

Expected result

month    seller_id  gmv
-------  ---------  ------
2026-01  2          700.00
2026-02  1          300.00
2026-02  3          300.00

Premium problem

This one's part of Premium. Unlock the full MySQL track plus every other premium problem on the site.

Write one SELECT query