Search ⌘K
O
Oracle

Foundations Track · Easy · 15 min

6. Average Sales Revenue by Product Category for Oracle

As a tech company, Oracle offers a diverse range of products including databases, cloud solutions, and other software services. The company would likely be i...

Foundations Track
Easy
15 min
aggregation
date functions

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

Timer 00:00
Back to practice

Objective

Practice aggregation through a Oracle-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

As a tech company, Oracle offers a diverse range of products including databases, cloud solutions, and other software services. The company would likely be interested in understanding the average sales revenue by product category. The marketing team at Oracle wants to understand the **average sales revenue made for each product category each month.** Given a relational table called 'sales' with columns sales_id(unique identifier for the sale), product_id(unique identifier for the product), category_id(unique identifier for product category), sales_date(date of the sale), and revenue(revenue from sale), **write an SQL query that retrieves the average revenue per product category for each month.** sales **Example Input:** sales_id product_id category_id sales_date revenue -------------------------------------------------------- 1001 5001 1 06/18/2022 3500 1002 6985 2 06/18/2022 4700 1003 5001 1 07/27/2022 3700 1004 6985 2 08/25/2022 5000 1005 5000 1 06/18/2022 3000 **Example Output:** month category avg_revenue ------------------------------ 6 1 3250 6 2 4700 7 1 3700 8 2 5000 **Answer:** SELECT EXTRACT(MONTH FROM sales_date) AS month, category_id AS category, AVG(revenue) AS avg_revenue FROM sales GROUP BY 1, 2 ORDER BY 1, 2 ---

sales
sales_id INT PRIMARY KEY
product_id INT NOT NULL
category_id INT NOT NULL
sales_date DATE NOT NULL
revenue NUMERIC(12
2
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.