60.9k views
3 votes
Write a query to find the customer balance summary (total, min, max, avg) for all customers who have not made purchases during the current invoicing period

1 Answer

2 votes

Answer:

SELECT SUM(customer_balance) as Total, MIN(customer_balance) as minimum_balance, Max(customer_balance) as maximum_balance, AVG(customer_balance) as average_balance FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM invoice)

Step-by-step explanation:

The SQL query statement returns four columns which are aggregates of the column customer_balance from the customers table in the database and the rows are for customers that have not made any purchase during the current invoicing period.

User Thm Lee
by
8.3k points