Keep SQLtest alive: Help cover this month's $100 server costs to keep all lessons and the SQL playground online. Support the project →
SQL code copied to buffer
Task 43:

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