SQL | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

SQL

Write a query to output the apartments whose prices are greater than the average and are also not rented, sorted by the 'Price' column. What is wrong with this code?! 1SELECT * FROM Apartments 2 WHERE AVG (Price)< price AND Status = Notrented 3 ORDER BY Price

29th Jan 2022, 4:45 PM
Neda Soufieh
Neda Soufieh - avatar
5 Answers
+ 4
Status is a string so notrented should be inside single quotes. And you have to get AVG of price then compare with price so there should be price > (SELECT AVG(price) FROM appartments)
29th Jan 2022, 4:49 PM
A͢J
A͢J - avatar
0
Project 28 ZOO
31st Jan 2022, 10:09 PM
Neda Soufieh
Neda Soufieh - avatar
0
Also this one : SELECT Names FROM Cake WHERE calories <= 100 ORDER BY calories LIMIT 3 ;
31st Jan 2022, 10:30 PM
Neda Soufieh
Neda Soufieh - avatar
0
Neda Soufieh You have to select all columns data not only Names and also no need to compare calories. That's not in task. So remove calories <= 100 Read task carefully and do accordingly, don't write anything else.
1st Feb 2022, 3:47 AM
A͢J
A͢J - avatar
0
Neda Soufieh In Zoo project first insert new data then select data using JOIN
1st Feb 2022, 3:50 AM
A͢J
A͢J - avatar