Return name and price of every product whose price is higher than the average price of all products. Sort by price from high to low, then by name.
Hint 1
You cannot write WHERE price > AVG(price). Put the average in a subquery.
Reference solution
SELECT name, price
FROM products
WHERE price > (SELECT AVG(price) FROM products)
ORDER BY price DESC, name;
An aggregate is not allowed in WHERE, because WHERE looks at one row at a time and the average needs all rows. The subquery (SELECT AVG(price) FROM products) is evaluated first and returns one value, which the outer WHERE then uses like any number. Run the inner query alone first to see that value.