#300

Top Sellers by Revenue

A marketplace needs to identify revenue leaders. The Product catalogue holds items with a UUID id, unit_price NUMERIC(15,2), an ENUM category and JSONB attributes. The Sales table records transactions: sale_id UUID, seller_id, a product reference, quantity, the actual per-unit price charged on the sale price NUMERIC(15,2) (which can differ from the catalogue price because of discounts), the moment of sale sold_at TIMESTAMPTZ and a payment-method ENUM. Row-level revenue = quantity * price. Find sellers with the maximum total revenue across all sales. If several sellers tie for first place, return them all. Result column: seller_id, sorted ascending.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.

seller_id
2

Your query result will appear here