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

62) Write a query to display the largest average product price of any brand. 63)

ID: 3670222 • Letter: 6

Question

62) Write a query to display the largest average product price of any brand.

63) Write a query to display the brand ID, Brand name, brand type, and average price of products for he brand that has the largest average product price.

64.) Write a query to display the manger name, department name, epartment phone number, employee name, customer name, invoice date, and invoice totalfor the department manager of the emploee who made a sale to a customer whose last name is Hagan on May 18, 2013. For all person names, concatenate the first and last names into a single field.

Please be as clear as possible. I am a beginner and just trying to learn and understand how to write these queries. Thanks!

Explanation / Answer

1.

SELECT Max(AVGPRICE) AS “LARGEST AVERAGE”FROM (SELECT BRAND_ID, Round(Avg(PROD_PRICE),2) AS AVGPRICEFROM LGPRODUCT PGROUP BY BRAND_ID);

2.

SELECT P.BRAND_ID, BRAND_NAME, BRAND_TYPE, Round(Avg(PROD_PRICE),2) AS AVGPRICE FROM LGPRODUCT AS P, LGBRAND AS B WHERE P.BRAND_ID = B.BRAND_ID GROUP BY P.BRAND_ID, BRAND_NAME, BRAND_TYPE HAVING Round(Avg(PROD_PRICE),2) = (SELECT Max(AVGPRICE) AS "LARGEST AVERAGE" FROM (SELECT BRAND_ID, Round(Avg(PROD_PRICE),2) AS AVGPRICE FROM LGPRODUCT P GROUP BY BRAND_ID));