Find customer with highest balance

To find the customer with the highest balance, you can use a simple SQL query as follows: SELECT customer_id, name, balance FROM customers ORDER BY balance DESC LIMIT 1

Problem

Given a table of customer information, write a SQL query to find the customer with the highest balance.
Example input:
| customer_id | name       | balance |
|--------------|------------|---------|
| 1            | John Smith | 100.00  |
| 2            | Jane Doe   | 200.00  |
| 3            | Joe Shmoe  | 300.00  |
Example output:
| customer_id | name       | balance |
|--------------|------------|---------|
| 3            | Joe Shmoe  | 300.00  |

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT customer_id, name, balance
FROM customers
ORDER BY balance DESC
LIMIT 1;

/*

The solution above is optimal because it uses the ORDER BY and LIMIT clauses to sort the table by balance in descending order and then return the first row.

*/

A.I. Evaluation of the Solution

The solution above is optimal because it uses the ORDER BY and LIMIT clauses to sort the table by balance in descending order and then return the first row.

Evaluated at: 2022-11-22 10:16:17