134k views
5 votes
Determine the profit of each book sold to Jake Lucas, using the actual price the customer paid (not the book’s regular retail price). Sort the results by order date. If more than one book was ordered, sort the results by profit amount in descending order. Perform the search using the customer name, not the customer number.

User Loup
by
7.3k points

1 Answer

5 votes

The search using the customer name, not the customer number is as follows

Step-by-step explanation:

Using JOIN

Apply the natural join on the customers, orders, the order items & the books table. Where the Customer table contains the details of the customer and the order , the order items table will contain details about order of the books given by the customer.

SELECT Title, Paid Each- AS Profit From CUSTOMERS natural join ORDERS natural join ORDERITEMS natural join BOOKS Where FirstName = 'Jake' AND Last Name = 'Lucas' Order BY Order Date, Profit;

User Jonas Wolf
by
7.1k points