Counting customer orders

This technical problem involves writing a SQL query to find the total number of orders placed by each customer, based on a table of customer order data.

Problem

Given a table of data representing customer orders, write a SQL query to find the total number of orders placed by each customer.
Example input:
Customer 1| Order 1
Customer 1| Order 2
Customer 2| Order 1
Customer 2| Order 2
Customer 2| Order 3
Example output:
Customer 1| 2
Customer 2| 3

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT customer, COUNT(*) AS total_orders
FROM orders
GROUP BY customer;

/*

The above solution is optimal because it uses the GROUP BY clause to group the orders by customer, and then uses the COUNT() function to count the number of orders for each customer.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, as it uses the GROUP BY clause to group the orders by customer, and then uses the COUNT() function to count the number of orders for each customer.

Evaluated at: 2022-11-13 08:15:33