Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DATABASE SQL QUERIES WRITING SQL QUERIES FOR THE FOLLOWING STATEMENTS. PERFORM S

ID: 3790762 • Letter: D

Question

DATABASE SQL QUERIES


WRITING SQL QUERIES FOR THE FOLLOWING STATEMENTS.

PERFORM SQL QUERIES FOR THE FOLLOWING STATEMENTS

ER MODEL IS GIVEN BELOW

f For each customer, count the number of each type of product they have purchased. Customers must be listed even if they have azero count for one or more types of products. The types of products to be considered are Bread, Cake and Cup Cake. List the customer name, cid and the three count values. The output must be sorted by cid. g List the pid and name of any products that were not sold. Sort the output by pid. h Different amounts of ingredients are used by different recipes. Find the smallest amount of ingredient that is used and list those recipes that use that amount of ingredient. List, rid, name of recipe, name of ingredient and quantity

Explanation / Answer

select customername,cid, count(bread),count(cake),count(cupcake) from customer outer join product on customer.pid=customer.pid group by customername,cid select pid from product inner join address on product.pid=address.id where deliverydate is not null order by pid select rid, rec.name,ing.name,ing.quantity from recipe rec inner join ingredient ing on recipe.ingname=ing.name having min(rec.quantity)