sql · level 1 check

the shop owner's questions.

Time for a real job! You look after the databases for a group of shops. Every shop has a table called `products`, with the columns `name`, `category`, `price` (in whole pounds) and `stock`.

The owner has four questions. How many products are there? Which products have sold out? What are the three dearest products, dearest first? And how much is all the stock worth, if you multiply each price by its stock and add them up?

Answer each question with one query, in that order, and keep the names `product_count` and `stock_value`. Your queries will be run on five different shops, so they must work for any shop, not only this one. Fill in each `____` and run it.

Fill in every ____ then run the checks.
  1. 1 It counts every product in the corner shopuses: COUNT
  2. 2 It finds only the sold-out toysuses: WHERE
  3. 3 It lists the three dearest garden products, dearest firstuses: ORDER BY and LIMIT
  4. 4 It works out what the sports stock is worthuses: SUM and maths
  5. 5 It answers every question for a shop where nothing has sold outuses: putting it together

Take as long as you like and try as many times as you want.