logo

Back to questions

Product Line Revenue

Easy

As a business analyst on the revenue forecasting team at NVIDIA, you are given a table of NVIDIA transactions in 2021.

Write a query to summarize the total sales revenue for each product line. The product line with the highest revenue should be at the top of the results.

Assumption:

  • There will be at least one sale of each product line.

Table:

Column NameType
product_idinteger
product_namevarchar
product_linevarchar

Example Input:

product_idproduct_nameproduct_line
1Quadro RTX 8000GPU
2Quadro RTX 6000GPU
3GeForce RTX 3060GPU
4BlueField-3DPU

Table:

Column NameType
transaction_idinteger
product_idinteger
amountinteger

Example Input:

transaction_idproduct_idamount
10115000
10224200
10339000
10447000

Example Output:

product_linetotal_revenue
GPU18200
DPU7000

Explanation

The total revenue for the GPU product line is $18,200 (5000 + 4200 + 9000), and $7,000 for the DPU product line.

PostgreSQL 14

Refer friends to get bonus content & cool prizes.