Why this code is not right in SQL apartment quiz? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why this code is not right in SQL apartment quiz?

SELECT * from apartments where ( price > ( Select avg(price) from apartments ) ) and ( status = 'Not Rented' ) order by price;

3rd May 2021, 6:47 AM
Agyad Keddeh
Agyad Keddeh - avatar
10 Answers
+ 3
Agyad Keddeh Try this: SELECT * FROM Apartments WHERE price>=(SELECT AVG(price)FROM Apartments) ORDER BY price;
3rd May 2021, 10:35 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 5
Your solution seems to be correct. You can also try this in this way: SELECT * FROM apartments where price > ( SELECT AVG(price) from apartments ) and status='Not rented' order by price; I think you are getting problem due to recent bug in SQL code coaches. Can you please upload the screenshot of your output and expected output?
3rd May 2021, 7:38 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
Agyad Keddeh I guessed correctly, it's due to a recent bug in SoloLearn, hope it will resolve soon. Till then you can try other things
3rd May 2021, 11:43 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 2
AKSHAY🇮🇳 [INACTIVE] Thank you very much brother 👍🏻
4th May 2021, 6:12 AM
Agyad Keddeh
Agyad Keddeh - avatar
+ 2
❤️😍Prerana😍❤️ Your code is working my friend, thanks alot. But why omitting the not rated condition makes it right, the quiz asked for this condition on the first place?!! 🤔
4th May 2021, 6:21 AM
Agyad Keddeh
Agyad Keddeh - avatar
+ 2
Agyad Keddeh Welcome But I really don't have any idea about it.
4th May 2021, 6:57 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 1
There may be some mistake on your database,ins.
3rd May 2021, 7:21 AM
VuxxLong
VuxxLong - avatar
+ 1
How can I upload a screen shot here?! I'm sorry I am new here, thanks in advance for answering me my friend
3rd May 2021, 9:14 AM
Agyad Keddeh
Agyad Keddeh - avatar
+ 1
Agyad Keddeh currently SoloLearn doesn't support sharing images in discuss section. What you can do is post it in your feed and then share the post link here https://www.sololearn.com/post/903/?ref=app
3rd May 2021, 11:13 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar