You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND (CASE WHEN listings.listing_status = 1 THEN list_price WHEN listings.list' at line 13