What's the total revenue for all items? SELECT sum(revenue) FROM items; 3800
What's the average revenue for all items? SELECT avg(revenue) FROM items; 950.000
What's the minimum revenue for all items? SELECT min(revenue) FROM items; 500
What's the maximum revenue for all items? SELECT max(revenue) FROM items; 1200
What the count for items with a name? SELECT count(name) FROM items; 4
Write queries for the following:
Return all main courses. Hint: What ActiveRecord method would you use to get this? SELECT * FROM items WHERE course = 'main';
Return only the names of the main courses. SELECT name FROM items WHERE course = 'main';
Return the min and max value for the main courses. SELECT min(revenue), max(revenue) FROM items WHERE course = 'main';
What's the total revenue for all main courses? SELECT sum(revenue) FROM items WHERE course = 'main';