🎯 Few days left this month Support SQLTest.online and help us keep SQL practice free for everyone. Donate today →
SQL code copied to buffer
Task

Product Sales Analysis

SQL Server 2022
Retrieve a list of distinct products along with their category names, total sales amount, and their value relative to both their category and the overall total. The output should include columns for ProductID, ProductCategoryName, ProductName, SalesAmount, ValuePerCategory, and ValuePerTotal. 
Sort the results primarily by ValuePerTotal in descending order, followed by ValuePerCategory and SalesAmount.

Question by: Iason Kas

Expected result Columns: 6 · Rows: 295
ProductID ProductCategoryName ProductName SalesAmount ValuePerCategory ValuePerTotal

Sample rows open after wrong checks: 0 of 3

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial
The query result will appear here. Ctrl+Enter - Run query