28. GROUP BY over a range

This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
 

Given a table that contains 30 products. Each row in the table specifies the product number, name, and price.
As shown in the (partial) image, the product prices vary between 10 and 300, in the following manner: The product price = the product number * 10.
For example: The cost of product number 2 = 20, product number 11 = 110, product 21 = 210, product 30 = 300, and so on.


CREATE TABLE Products
(productID int,
ProductName varchar(25),
ProductPrice int)
GO

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…