+ 4

SQL Apartments question.

So this is the code that I wrote and it passed... SELECT * FROM Apartments WHERE price > (SELECT AVG(price) FROM Apartments) ORDER BY price; But it also tells you to account for status and to only include rows with status = "Not Rented". So say I have a Apartment that is greater than price but also "Rented", how would I incorporate that into the command? I couldn't figure it out...

2nd May 2022, 2:50 AM
Dylan Campbell
Dylan Campbell - avatar
1 Answer
+ 5
You can add multiple conditions to your WHERE clause. Text must be enclosed by apostrophes (single quote). SELECT * FROM Apartments WHERE price > (SELECT AVG(price) FROM Apartments) AND status = Not Rented ORDER BY price; (the forum does not allow me to save with single quotes)
2nd May 2022, 3:18 AM
Tibor Santa
Tibor Santa - avatar