In: Computer Science
Can you please implement this in Oracle sql
The email_address from the Customers table
A count of the number of orders
The total amount for each order (Hint: First, subtract the discount amount from the price. Then, multiply by the quantity.)
Return only those rows where the customer has more than 1 order.
Sort the result set in descending sequence by the sum of the line item amounts.
Customer table:
Order table:
Query:
SELECT
c.email_address, SUM((o.price - o.discount)*o.quantity) AS
amount,COUNT(o.cust_id) AS
num_of_orders FROM `customer` c INNER JOIN `orders` o
ON c.oid = o.oid GROUP BY o.cust_id HAVING num_of_orders > 1
ORDER BY amount DESC
Result: