Product Line Revenue
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.
|1||Quadro RTX 8000||GPU|
|2||Quadro RTX 6000||GPU|
|3||GeForce RTX 3060||GPU|
The total revenue for the GPU product line is $18,200 (5000 + 4200 + 9000), and $7,000 for the DPU product line.
First, we'll calculate the total sales for each product line. The field in the table can be used to obtain sales figures, but this table doesn't have product line information. With the help of , we'll get the data from both tables into one place.
It should look something like this:
The output for the GPU line should look something like this:
|Quadro RTX 8000||GPU||5000|
|Quadro RTX 6000||GPU||4200|
|GeForce RTX 3060||GPU||9000|
Note: Except for those mentioned in the clause, all other columns in clause must be given an aggregate function.
Sort the results by descending, as specified in the problem statement.
You did it!
Solution #2: Using Window function
Here, we use a window function and a clause instead of .