0
What is the mistake?
SELECT * FROM Apartments WHERE price>=(SELECT AVG(price)FROM Apartments) ORDER BY price; What is my mistake? 🥴
11 Antworten
+ 3
Miguel Fortes Gutiérrez
Try this:
SELECT * FROM Apartments
WHERE price>=(SELECT AVG(price)FROM Apartments)
ORDER BY price;
+ 2
Brian I think SoloLearn is currently facing issue with SQL code coaches.
In other words, SL is showing expected output in title case and our output will be in lower case. That's why we are getting test case failed.
+ 2
AKSHAY🇮🇳 [INACTIVE] I agree, there is a problem with Code Coach upper/lowercase at the moment. My query once passed, and I find that now it fails.
I did some "black box" testing and found a kluge that allows it to pass again. I narrowed it down to something related with the capital N in "Not rented". I reported my findings to info@sololearn.com.
+ 1
The query's syntax is valid, though it seems it's not optimized.
you can even check it at https://www.eversql.com/sql-syntax-check-validator/
if you are using pdo sometimes you need this syntax
SELECT * from database.table WHERE ..........
+ 1
The Code Coach task is this:
"Write a query to output the apartments whose prices are greater than the average and are also not rented, sorted by the 'Price' column."
The query needs to filter records to show only "not rented" apartments.
Also notice that it says "greater than", not "greater than or equal to".
https://www.sololearn.com/coach/1057?ref=app
0
The syntax is valid, the program of SoloLearn is possible error?
0
could it be that you need to order in descending order (highest to lowest)? right now you are sorting from lowest to highest.
to order in descending order you need to add “desc” at the end of order by - order by price desc.
0
Order by desc? 🥴
0
i am assuming this is a challenge, or some sort of practice for you to get a specific result. since the query looks ok, the only thing i can think that could be wrong is the sorting order for price.
order by price desc will sort your list by highest price to lowest price.
right now you are sorting lowest price to highest price.
0
Is correct Prerana thanks very much
0
Miguel Fortes Gutiérrez
Welcome ☺️☺️