Book History
Lesson 2 of 3 in Coddy's SQL Challenges pack #1 course.
Challenge
MediumA chocolate factory does not have enough resources. Chocolate must have 243 grams of sugar to be tasty. Each chocolate brand has a limited amount of sugar.
The factory also has a history book. The book shows how many chocolates the factory made for specific days and for which brand.
For each brand, extract the average chocolates (from the book table) that were made, round the result to 2 decimals places, and extract the number of chocolates the factory can produce now (from the factory table).
Name the columns brand, choc_num, choc_avg. Sort the results by choc_avg in descending order.
Try it yourself
SELECT brand, sugar / 243 as choc_num
FROM factory