# Find Revenue by Department — SQL Interview Question

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/questions/3965/find-revenue-by-department
Source observed: 2026-11-04T23:18:07.362Z
Last checked: 2026-11-04T23:18:07.362+00:00
Indexed: 2026-11-07T01:54:29.222+00:00

---

# Find Revenue by Department

**Difficulty:** Medium  
**Categories:** [Coding](https://www.aced.io/questions?type=coding), [SQL](https://www.aced.io/questions?type=sql)  
**Interview:** Coding  
**Reported last asked:** 2 years ago

We provide interview-practice questions and coding tools through Aced, formerly Exponent. This question asks you to write a SQL query that calculates revenue by department from relational tables.

## Problem

You are given the following tables.

### `orders`

| Column | Type |
| --- | --- |
| `order_id` | integer |
| `customer_id` | integer |
| `order_date` | date |
| `order_amount` | integer |
| `department_id` | integer |

### `departments`

| Column | Type |
| --- | --- |
| `department_id` | integer |
| `department_name` | string |

### `customers`

| Column | Type |
| --- | --- |
| `customer_id` | integer |
| `first_name` | string |
| `last_name` | string |

## Required result

Order the departments from highest to lowest revenue in the last 12 months. Return exactly these output columns:

- `department_name`
- `total_revenue`

The customer table is included in the schema, although the requested output concerns department names and revenue.

## Access and practice controls

Detailed company statistics for this question require an [upgrade](https://www.aced.io/upgrade?src=questions). Users can [sign up to run code](https://www.aced.io/signup?src=lesson). The question interface includes Question, Solution, and Community tabs, plus Editor, Share, Output, Test Results, and Console controls.

No community answers have been contributed yet.

## Related questions

- [Find Customers by Department](https://www.aced.io/questions/3966/find-customers-by-department)
- [Rank Salary by Department](https://www.aced.io/questions/4379/rank-salary-by-department)
- [Top Salaries by Department](https://www.aced.io/questions/3045/top-salaries-by-department)

## More from Aced

We offer interview preparation courses and practice resources, including:

- [Product Management](https://www.aced.io/courses/pm?src=nav) — Ace product interviews from strategy cases to technical skills.
- [Forward Deployed](https://www.aced.io/courses/forward-deployed-engineering?src=nav) — Beta preparation for FDE loops at Anthropic, OpenAI, Palantir, and more.
- [Engineering Management](https://www.aced.io/courses/engineering-management?src=nav) — Review leadership and people-management skills.
- [Software Engineering](https://www.aced.io/courses/software-engineering?src=nav) — Learn strategies for coding problems and more.
- [System Design](https://www.aced.io/courses/system-design-interviews?src=nav) — Define architectures, interfaces, and databases in a time crunch.
- [Data Science](https://www.aced.io/courses/data-science?src=nav) — Execute statistical techniques and experimentation effectively.
- [Machine Learning](https://www.aced.io/courses/ml-engineer?src=nav) — Review building, evaluating, and deploying AI/ML models.
- [Data Engineering](https://www.aced.io/courses/data-engineering?src=nav) — Design complex data models and ETL pipelines.
- [AI Engineering](https://www.aced.io/courses/ai-engineering?src=nav)
- [Investment Banking](https://www.aced.io/ib?src=nav)
- [Generative AI](https://www.aced.io/courses/gen-ai-interviews?src=nav)
- [Security Engineer](https://www.aced.io/courses/security-engineer?src=nav)
- [TPM](https://www.aced.io/courses/tpm?src=nav)
- [Solutions Architect](https://www.aced.io/courses/solution-architect-interview?src=nav)
- [UX / Product Design](https://www.aced.io/courses/product-designer-interview?src=nav)
- [BizOps & Strategy](https://www.aced.io/courses/bizops?src=nav)

Other resources include [Loops](https://www.aced.io/guides?src=nav), [Experiences](https://www.aced.io/experiences?src=nav), [Practice](https://www.aced.io/practice?src=nav), [Coaching](https://www.aced.io/coaching?src=nav), [Pricing](https://www.aced.io/upgrade?src=nav), [Job Referrals](https://www.aced.io/jobs/referrals?src=nav), and [Resources](https://www.aced.io/resources?src=nav).

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3965%2Ffind-revenue-by-department&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fquestions%2F3965%2Ffind-revenue-by-department). Opening a form does not execute a tool.