- SELECT SUM(revenue) FROM items;
- SELECT AVG(revenue) FROM items;
####Minimum revenue for all items?
- SELECT MIN(revenue) FROM items;
- SELECT MAX(revenue) FROM items;
- SELECT COUNT(name) FROM items;
- SELECT COUNT(*) FROM items;
- SELECT * FROM items WHERE course='main';
- SELECT name FROM items WHERE course='main';
- SELECT MAX(revenue), MIN(revenue) FROM items WHERE course='main';
- SELECT SUM(revenue) FROM items WHERE course='main';
-
SELECT items.name AS item_name, seasons.name AS season_name FROM items INNER JOIN seasons ON items.season_id = seasons.id;
-
SELECT items.name AS item_name, categories.name AS category_name FROM items INNER JOIN items_categories on items.id = items_categories.item_id INNER JOIN categories on items_categories.category_id= categories.id WHERE items.name = 'arugula salad';
-
SELECT * FROM items WHERE revenue < (SELECT AVG(revenue) FROM items);
-
SELECT SUM(i.revenue) FROM items i INNER JOIN items_categories ic ON i.id = ic.item_id INNER JOIN categories c ON ic.category_id = c.id WHERE c.name='dinner';
-
SELECT c.name, SUM(i.revenue) FROM items i INNER JOIN items_categories ic ON i.id = ic.item_id INNER JOIN categories c ON ic.category_id = c.id GROUP BY c.name;
- Returns a table from two tables where the rows have matching values
- Returns a table with all rows from the table on the left hand side of the query, and the matching values on the right table
- Returns a table with all rows from the table on the right hand side of the query, and the matching values on the left table