I have created a table as follows:
create table products
(productID int not null auto_increment,
Name varchar(30),
Price float ,
CoffeOrigin varchar(30),
primary key (productID));
Now the question is "Display the name of products whose price is less than average price."
My 1st attempt:
select Name from products having Price <= avg(Price);
It is giving me error as Error Code: 1054. Unknown column 'Price' in 'having clause'
My 2nd attempt:
select * from products having Price <= avg(Price);
It is giving me incomplete output. Here average Price is 3.14 but is only products with price less than 3 are being displayed in the result.