For each of the following user data requests, create a query to retrieve the req
ID: 3656793 • Letter: F
Question
For each of the following user data requests, create a query to retrieve the requested data. Record the query and the number of rows returned by the query. When you have a choice, use joins instead of subqueries.
" I want a full list of customer names in customer number order. For each customer, I want the name of the assigned salesperson and the headquarters city."
"I want a full list of customer names. For each customer, I want the name of the assigned salesperson. I also want the names and the titles of any customer employees. I need this list in salersperson order, by name." Why does this query return more rows than the full list of customer names in customer number order?
Explanation / Answer
SELECT customer_name,customer_number,assigned_salesperson,head_quarters
FROM customers
ORDER BY customer_number
======================
SELECT customer_name,assigned_salesperson_name,
FROM customers
ORDER BY assigned_salesperson_name
//// I did not understand what you meant by customer employees. Sorry Please elaborate .I did this so far!
=====================
And we will have more number of rows in the 2nd query because we are also adding cutomer emploee rows to the full list of customers.
And we are performing OUTER JOIN so we may get larger than full list of customers.
Which is very much common.
Cheers !! :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.