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

2. Determine the average customer balance by representative. Show the resulting

ID: 3835655 • Letter: 2

Question

2. Determine the average customer balance by representative. Show the resulting average along with the representative's full name as "last name, first name" in a single column, order by the representative's last name

RepNum LastName FirstName Street City State PostalCode Commission Rate Item ItemNum Description On Hand Category Storehouse Entity names Customer Customer Num CustomerName Street City State PostalCode Balance CreditLimit RepNuma Orders Order N OrderDate Column names Customer Num appear inside rectangles Orderline Order N Item Num Numordered Quoted Price An entity appears as a rectangle Line indicates a relationship Absence of a dot indicates the "one" part of the relationship Dot indicates the "many" part of the relationship

Explanation / Answer

ANSWER:

Determine the average customer balance by representative.

SELECT Avg(Balance)
FROM Customer
GROUP BY RepNum;

Show the resulting average along with the representative's full name as "last name, first name" in a single column, order by the representative's last name

SELECT CONCAT(R.Lastname,' ', R.FirstName) AS FULLNAME, Avg(C.Balance)
FROM Rep R JOIN Customer C
ON (R.RepNum = C.RepNum)
ORDER BY R.LastName;


Final Query:
Determine the average customer balance by representative.Show the resulting average along with the representative's full name as "last name, first name" in a single column, order by the representative's last name.


SELECT CONCAT(R.Lastname,' ', R.FirstName) AS FULLNAME, Avg(C.Balance)
FROM Rep R JOIN Customer C
ON (R.RepNum = C.RepNum)
GROUP BY C.RepNum
ORDER BY R.LastName;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote