48. Calculating Product Sales

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.

A store that sells M&M’S products manages two major tables.
The first table specifies the various products and their number in the inventory:


CREATE TABLE products_stock
(productID int identity(1,1),     
 productName varchar(150),     
 unitsInStock int    


The second table specifies the sales of these products:

CREATE TABLE products_sales    
(saleID int identity(1,1),    
 productID int,    
 unitsSold int,     
 customerID int    

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…