Find the average price of all products in a database.

This technical problem involves writing a SQL query to find the average price of all products in a database. An example product table is provided, and the expected output is the average price of all products in the table.

Problem

Write a SQL query to find the average price of all products in the database.
Example input:
Product table:
+----+-------------+-------------+
| id | name        | price      |
+----+-------------+-------------+
| 1  | Product 1   | 10.00      |
| 2  | Product 2   | 20.00      |
| 3  | Product 3   | 30.00      |
+----+-------------+-------------+
Output:
+-------------+
| average     |
+-------------+
| 20.00       |
+-------------+

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT AVG(price) AS average
FROM Product;

A.I. Evaluation of the Solution

This solution is complete and solves the problem. The approach is straightforward and easy to understand.

Evaluated at: 2022-11-21 14:16:15