Find the Cheapest Product in a SQL Database

Write a SQL query to find the cheapest product in a given table. The table schema is provided, and an example input and output are given.

Problem

Given a table of products with the following schema:
CREATE TABLE products (
id INTEGER,
name TEXT,
price INTEGER
);
Write a SQL query to find the cheapest product.
Example input:
id | name | price
1 | Product A | 10
2 | Product B | 20
3 | Product C | 30
Example output:
id | name | price
1 | Product A | 10

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT * FROM products ORDER BY price ASC LIMIT 1;

/*

The above query is optimal because it uses the ORDER BY clause to sort the products by price in ascending order, and then uses the LIMIT clause to return the first row.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of SQL.

Evaluated at: 2022-11-09 04:15:39