Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. SELECT
  2. ( ( avgWithCriteria - totalAverage ) / ( ( avgWithCriteria + totalAverage ) / 2 ) ) * 100 as percentDifference,
  3. a.*
  4. FROM
  5. (SELECT
  6. AVG( CASE WHEN 'f' not in ( has_free_parking ) THEN price ELSE null END) as avgWithCriteria,
  7. AVG( CASE WHEN 'f' in ( has_free_parking ) THEN price ELSE null END) as avgWithoutCriteria,
  8. AVG( price ) as totalAverage,
  9. neighbourhood_cleansed
  10. FROM listings
  11. WHERE city_name="berlin"
  12. AND price <= 1000000
  13. AND price >= -1
  14. AND reviews_per_month <= 1000000
  15. AND reviews_per_month >= -1
  16. AND est_monthly_income <= 1000000
  17. AND est_monthly_income >= -1
  18. GROUP BY neighbourhood_cleansed ) a;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement