Answering first four subparts. For others, please create
seperate question.
Kindly upvote if this helped
you.
Q1 - Saul wants to buy a new writer's desk, but he doesn't
want to spend more than $350. Write a select statement to find
products matching these requirements
A1 - SELECT * FROM <table_name> WHERE PROD_TYPE =
'DESK' AND cost<='350';
- Assumption made
- Please give table name as per the statement. This is just a
template
- The relation/table has a column called PROD_TYPE and its value is
'DESK' for desk products
- The relation/table has a column called cost which tells the cost
of the item.
Q2 - For each customer, list the customer
name and city and state in this format: City, State (one
column)
A2 - SELECT CONCAT(CITY,",",STATE) , NAME FROM
<table_name>;
- Assumption made
- Please give table name as per the statement. This is just a
template
- The relation/table has a column called NAME and its value is
customers name
Q3 - Display only those orders where more
than one different product has been ordered
A3 - SELECT ORDER_ID, COUNT(DISTINCT
PROD_ID) as count FROM <customer_table> AS C
INNER JOIN <orders_table> AS O ON C.customer_ID =
O.customer_ID
GROUP BY C.customer_ID, customer_name
HAVING COUNT(DISTINCT PROD_ID) > 1
- Assumption made
- Please give table name as per the statement. This is just a
template
- There are two tables customer and orders. Order info we have in
customer table and the corresponding products in the orders we have
in prod table. We are joining the tables and based on distinct prod
id, we are saying that particular order has different
products.
Q4 - Find the average price of
bookcases
A4 - SELECT AVG(BOOKCASES) FROM <table_name>;
- Assumption made
- Please give table name as per the statement. This is just a
template
- The relation/table has a column called BOOKCASES
and its value is price of bookcase
Get Answers For Free
Most questions answered within 1 hours.