Consider the following SQL table named 'orders': CREATE TABLE orders ( orderid INT,…
- User
Consider the following SQL table named 'orders':
CREATE TABLE orders ( order_id INT, quantity INT, product_price DECIMAL(5,2), product_name VARCHAR(100), order_date DATE );
What would be the correct SQL command to calculate the average product price, ignoring NULL values and duplicates, of all orders that have a quantity greater than 10? Select one or more options from the list Report a typo HINT by avatar Samarth Jain avg = sum/count also Was this hint helpful?
SELECT AVG(product_price) FROM orders WHERE quantity > 10;
SELECT AVG(DISTINCT product_price) FROM orders;
SELECT AVG(product_price) FROM orders;
SELECT AVG(DISTINCT product_price) FROM orders WHERE quantity > 10;
SELECT SUM(DISTINCT product_price) / COUNT(DISTINCT product_price) FROM orders WHERE quantity > 10;
- Assistant
To correctly calculate the average product price while ignoring duplicates and ensuring the quantity is greater than 10, we need to consider the specific conditions mentioned. The command should take into account only unique prices (
DISTINCT) to avoid duplicates, and it should specifically focus on orders where the quantity exceeds 10.From the options listed, here are the relevant evaluations: