4. List all the customer representatives and their corresponding customers. Incl
ID: 3835663 • Letter: 4
Question
4. List all the customer representatives and their corresponding customers. Include the representative last name and the customer name, order by the rep's last name in descending order.
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 relationshipExplanation / Answer
We have to select customer representatives and their corresponding customers, using the fact that 'RepNum' is the foreign key referenced by Customer which indicates its representative and there is a one-many relationship between Rep and Customer, since one representative can have many customers whereas each customer has exactly one representative. An inner join with the condition "Customer.RepNum = Rep.RepNum" and ordering with "DESC" on Rep.LastName yields the result. The SQL query is as follows:
ORDER BY Rep.LastName DESC;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.