You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Exercise_3.4.sql 394B

12345678910111213
  1. SELECT
  2. c.email_address AS email,
  3. COUNT(o.order_id) AS number_orders,
  4. SUM((oi.item_price - oi.discount_amount) * oi.quantity) AS sum_of_line_item_amounts
  5. FROM
  6. customers c
  7. JOIN
  8. orders o ON c.customer_id = o.customer_id
  9. JOIN
  10. order_items oi ON o.order_id = oi.order_id
  11. GROUP BY c.email_address
  12. HAVING number_orders > 1
  13. ORDER BY sum_of_line_item_amounts ASC;