20 January 2018

itemCounts

My solution:
CREATE PROCEDURE itemCounts() 
BEGIN 
  SELECT item_name, 
         item_type, 
         COUNT(*) AS item_count 
  FROM   availableItems 
  GROUP  BY item_name, 
            item_type 
  ORDER  BY item_type, 
            item_name; 
END 

countriesInfo

My solution:
CREATE PROCEDURE countriesInfo() 
BEGIN 
  SELECT COUNT(*)        AS number, 
         AVG(population) AS average, 
         SUM(population) AS total 
  FROM   countries; 
END