Given tables MENU and ORDER_DETAIL, can you help me create a SQL select statemen
ID: 650324 • Letter: G
Question
Given tables MENU and ORDER_DETAIL, can you help me create a SQL select statement to find:
item name, price, and quantity sold
limit to 10 results returned
order by amount
display the items that sell the most
I need to join menu and order_detail tables and the columns within menu are menuid, item_name, and price while the columns within order_detail are orderid and qty
I am having trouble joining the tables to create the query. The tables are already created. I just need to make a select statement to query them.
Explanation / Answer
create table Orders
(
OrderID int primary key,
item_name varchar(10),
price money,
quantity int,
)
go
insert into Orders
select 1,'ABC', '2015-04-04', 40 union all
select 2,'ABC', '2015-04-05', 30 union all
select 3,'ABC', '2015-04-06', 25 union all
select 4,'DEF', '2015-04-07', 10
insert into OrderDetails
select 1, 1, 'Item A', 100 union all
select 2, 1, 'Item B', 150 union all
select 3, 2, 'Item C', 125 union all
select 4, 2, 'Item B', 50 union all
select 5, 2, 'Item H', 200 union all
select 6, 3, 'Item X', 100 union all
select 7, 4, 'Item Y', 50 union all
select 8, 4, 'Item Z', 300
SELECT column list
FROM table1
&nb sp; INNER JOIN table2
&nb sp; ON table1.col1=table2.col2
WHERE criteria
ORDER BY column list
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.