Aan de slagGa gratis aan de slag

Aggregating finances

In this exercise you would like to learn more about the differences in payments between the customers who are active and those who are not.

Deze oefening maakt deel uit van de cursus

Applying SQL to Real-World Problems

Cursus bekijken

Oefeninstructies

  • Find out the differences in their total number of payments by COUNT()ing the payment_id.
  • Find out the differences in their average payments by using AVG().
  • Find out the differences in their total payments by using SUM().
  • Ensure the aggregate functions GROUP BY whether customer payments are active.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT active, 
       ___ AS num_transactions, 
       ___ AS avg_amount, 
       ___ AS total_amount
FROM payment AS p
INNER JOIN customer AS c
  ON p.customer_id = c.customer_id
GROUP BY ___;
Code bewerken en uitvoeren