0

What is the mistake?

SELECT * FROM Apartments WHERE price>=(SELECT AVG(price)FROM Apartments) ORDER BY price; What is my mistake? 🥴

2nd May 2021, 6:51 PM
Miguel Fortes Gutiérrez
Miguel Fortes Gutiérrez - avatar
11 Respostas
+ 3
Miguel Fortes Gutiérrez Try this: SELECT * FROM Apartments WHERE price>=(SELECT AVG(price)FROM Apartments) ORDER BY price;
3rd May 2021, 10:30 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 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.
3rd May 2021, 11:18 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 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.
3rd May 2021, 5:11 PM
Brian
Brian - avatar
+ 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 ..........
2nd May 2021, 8:02 PM
Nima
+ 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
3rd May 2021, 5:11 AM
Brian
Brian - avatar
0
The syntax is valid, the program of SoloLearn is possible error?
2nd May 2021, 8:08 PM
Miguel Fortes Gutiérrez
Miguel Fortes Gutiérrez - avatar
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.
2nd May 2021, 8:18 PM
you are smart. you are brave.
you are smart. you are brave. - avatar
0
Order by desc? 🥴
2nd May 2021, 8:22 PM
Miguel Fortes Gutiérrez
Miguel Fortes Gutiérrez - avatar
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.
2nd May 2021, 8:26 PM
you are smart. you are brave.
you are smart. you are brave. - avatar
0
Is correct Prerana thanks very much
4th May 2021, 12:11 AM
Miguel Fortes Gutiérrez
Miguel Fortes Gutiérrez - avatar
0
Miguel Fortes Gutiérrez Welcome ☺️☺️
4th May 2021, 4:50 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar