Finding the Total Amount Spent by Each Customer

Given a list of customer names and their purchase amounts, this SQL query will find the total amount spent by each customer.

Problem

Given a list of customer names and their purchase amounts, write a SQL query to find the total amount spent by each customer.
Input:
Customer 1 | $100
Customer 2 | $50
Customer 3 | $75
Output:
Customer 1 | $100
Customer 2 | $50
Customer 3 | $75

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by AskAI
SELECT customer_name, SUM(purchase_amount)
FROM customer_purchases
GROUP BY customer_name;

/*

The above solution is optimal because it uses the GROUP BY clause to group the customer names together and then uses the SUM function to add up the purchase amounts for each customer.

*/

A.I. Evaluation of the Solution

The solution provided is correct and demonstrates a good understanding of SQL. The approach is clear and concise.

Evaluated at: 2022-10-28 19:39:52