Get the average price of all products in an unnormalized database table.

The problem is to write a query to return the average price of all products in an unnormalized database table. The table includes the attributes productID, productName, productDescription, and productPrice.

Problem

Given an unnormalized database table with the following attributes:
- productID
- productName
- productDescription
- productPrice
Write a query to return the average price of all products.
Example input:
- 1, "Product 1", "Description 1", 10
- 2, "Product 2", "Description 2", 20
- 3, "Product 3", "Description 3", 30
Example output:
- 20

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT AVG(productPrice) FROM products;

/*

The above query is optimal because it is the simplest way to get the average price of all products.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a level of completeness. The candidate's approach is straightforward and solves the problem efficiently.

Evaluated at: 2022-11-23 00:16:24