-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRDB_O1.sql
More file actions
39 lines (30 loc) · 906 Bytes
/
RDB_O1.sql
File metadata and controls
39 lines (30 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
USE restaurant_db;
-- 1. View the menu_items table. I
SELECT * FROM menu_items;
-- 2. Find the number of items on the menu.
SELECT COUNT(*) FROM menu_items;
-- 3. What are the least and most expensive items on the menu?
SELECT * FROM menu_items
ORDER BY price ASC;
SELECT * FROM menu_items
ORDER BY price DESC;
-- 4. How many Italian dishes are on the menu?|
SELECT COUNT(*) FROM menu_items
WHERE category="Italian";
-- 5. What are the least and most expensive Italian dishes on the menu?
SELECT *
FROM menu_items
WHERE category="Italian"
ORDER BY price ASC;
SELECT *
FROM menu_items
WHERE category="Italian"
ORDER BY price DESC;
-- 6. How many dishes are in each category?
SELECT category, COUNT(menu_item_id) as num_dishes
FROM menu_items
GROUP BY category;
-- 7. What is the average dish price within each category?
SELECT category, AVG(price) as avg_price
FROM menu_items
GROUP BY category;