Sales by Category

ASKED IN INTERVIEW
2pts
e Bay

Problem Statement

eBay marketplace analysts need to report on category performance for the current year (2026).

Write an SQL query to calculate the total sales amount for each product category for all orders placed in 2026.

Rules:

  • Only include orders placed between 2026-01-01 and 2026-12-31.
  • If a category has no sales in 2026, it does not need to be included in the result.
  • Output columns: category_name, total_sales.
  • Results must be sorted by total_sales in descending order. If sales are equal, sort by category_name in ascending order.
Tests your understanding of
Joins, Aggregation and Date Filtering

Input Tables

sales
order_id(INTEGER)product_id(INTEGER)order_date(DATE)price(DECIMAL)
11012026-02-01150
21012026-02-15150
31022026-03-01300
41032025-12-3150
51042026-01-01100
products
product_id(INTEGER)product_name(VARCHAR)category_id(INTEGER)
101Leather Jacket1
102Smartphone2
103Toaster3
104Jeans1
categories
category_id(INTEGER)category_name(VARCHAR)
1Fashion
2Electronics
3Home Appliances

Expected Output

category_name(VARCHAR)total_sales(DECIMAL)
Fashion400
Electronics300

Tags

EasyASKED IN INTERVIEWJoinsAggregationDate Filtering
10-15 min
81%

Hints