Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.79 KB | None | 0 0
  1. SELECT SELF.*,
  2. EXISTS (SELECT 1 FROM "webclient"."wc_dict_cache_allocation_price_exist" AS "wc" WHERE wc.allocation = SELF.id) AS "is_tour",
  3. "likes"."total_likes" AS "like",
  4. MIN("apt"."name") AS "alloc_place_type_name",
  5. MIN("alpv"."name") AS "alloc_place_value_name"
  6. FROM
  7. (SELECT SELF.id = ANY(ARRAY[190507,52772,68523,166677,104581,166820,52421,93291,166646]) AS recomended, rate,
  8. "self"."id",
  9. "self"."name",
  10. "self"."resort",
  11. "self"."resort_place",
  12. "self"."cat",
  13. allocation_type,
  14. "resorts"."name" AS "resort_name",
  15. "resorts"."name_eng" AS "resort_name_eng",
  16. "resorts"."country" AS "country"
  17. FROM "dict"."vw_dict_allocation" AS "self"
  18. JOIN "dict"."vw_dict_resort" AS "resorts" ON resorts.id = SELF.resort
  19. JOIN "lsh"."vw_lsh_allocation_stat" AS "ar" ON ar.allocation_id = SELF.id
  20. WHERE resorts.country = 83 OR (resorts.country = 83 AND SELF.id = ANY(ARRAY[190507,52772,68523,166677,104581,166820,52421,93291,166646]))
  21. ORDER BY recomended DESC, rate DESC, name
  22. LIMIT 15) SELF
  23. JOIN "dict"."vw_dict_country" AS "countries" ON countries.id = SELF.country
  24. LEFT JOIN "dict"."vw_dict_resort_place" AS "resort_place" ON resort_place.id = SELF.resort_place
  25. LEFT JOIN "dict"."vw_dict_alloccat" AS "alloccats" ON alloccats.id = SELF.cat
  26. LEFT JOIN "lsh"."lsh_hotel_like_info" AS "likes" ON likes.allocation_id = SELF.id
  27. LEFT JOIN "dict"."vw_dict_allocation_type" AS "at" ON at.id = SELF.allocation_type
  28. LEFT JOIN "dict"."vw_dict_rel_alloc_place_value" AS "rapv" ON rapv.allocation = SELF.id
  29. LEFT JOIN "dict"."vw_dict_alloc_place_value" AS "alpv" ON alpv.id = rapv.place_value
  30. LEFT JOIN "dict"."vw_dict_alloc_place_type" AS "apt" ON apt.id = alpv.place
  31. LEFT JOIN "dict"."th_allocation_stat" AS "ap" ON ap.allocation_id = SELF.id
  32. GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
  33. ORDER BY recomended DESC, rate DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement