Home > Enterprise >  ERROR: syntax error at or near "ORDER" LINE 3: ORDER BY price; ^ [closed]
ERROR: syntax error at or near "ORDER" LINE 3: ORDER BY price; ^ [closed]

Time:09-28

This is my code:

SELECT * FROM Apartments
WHERE price > AVG(price) AND Status = "not rented" AND
ORDER BY price;

but I get a syntax error

ERROR: syntax error at or near "ORDER"
LINE 3: ORDER BY price;
^

enter image description here

CodePudding user response:

select * FROM Apartments 
  WHERE price > (SELECT AVG(price) FROM APARTMENTS)
     and Status = 'not rented' 
ORDER BY price;

CodePudding user response:

 SELECT * FROM Apartments 
WHERE Price > (SELECT AVG(Price) FROM Apartments)
AND status="not rented"
ORDER BY price;
  •  Tags:  
  • sql
  • Related