Consider the following schema Product Vendors Orders Products Order Details Cust
ID: 3752571 • Letter: C
Question
Consider the following schema Product Vendors Orders Products Order Details Custcity Custstate VendorlD 8 ProductNumber Employees CategorylD LowSpend anuary February Sequence HighPrice May June ub August October Figure 1: Sales Orders Database Subtask 7.1.4 Examine this query SELECT CustFirstName, CustLastName, OrderDate FROM Customers c, Orders o WHERE o.CustomerlD-c.CustomerlD ORDER BY CustLastName, CustFirstName, OrderDate DESC; a) What do you think its purpose might be? (What do people want to know when they issue such a query?) b) Rewrite the query using proper JOIN syntax c) Modify the query to include the one customer who doesn't have an order. d) Modify the query to include only the latest order of each customer. Document and submit the solutionsExplanation / Answer
a) This query is to find all the customers who have ordered atleast once (made atleast one order) in descending order of their first, last names and order date.
b) SELECT CustFirstName, CustLastName, OrderDate From Customers c JOIN Order o ON c.CustomerID = o.CustomerID ORDER BY CustLastName, CustFirstName, OrderDate DESC;
c) SELECT CustFirstName, CustLastName FROM Customers WHERE CustomerID NOT IN (SELECT CustomerID FROM Orders) ORDER BY CustLastName, CustFirstName, OrderDate DESC LIMIT 1;
d)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.