Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT SELF.*,
- EXISTS (SELECT 1 FROM "webclient"."wc_dict_cache_allocation_price_exist" AS "wc" WHERE wc.allocation = SELF.id) AS "is_tour",
- "likes"."total_likes" AS "like",
- MIN("apt"."name") AS "alloc_place_type_name",
- MIN("alpv"."name") AS "alloc_place_value_name"
- FROM
- (SELECT SELF.id = ANY(ARRAY[190507,52772,68523,166677,104581,166820,52421,93291,166646]) AS recomended, rate,
- "self"."id",
- "self"."name",
- "self"."resort",
- "self"."resort_place",
- "self"."cat",
- allocation_type,
- "resorts"."name" AS "resort_name",
- "resorts"."name_eng" AS "resort_name_eng",
- "resorts"."country" AS "country"
- FROM "dict"."vw_dict_allocation" AS "self"
- JOIN "dict"."vw_dict_resort" AS "resorts" ON resorts.id = SELF.resort
- JOIN "lsh"."vw_lsh_allocation_stat" AS "ar" ON ar.allocation_id = SELF.id
- WHERE resorts.country = 83 OR (resorts.country = 83 AND SELF.id = ANY(ARRAY[190507,52772,68523,166677,104581,166820,52421,93291,166646]))
- ORDER BY recomended DESC, rate DESC, name
- LIMIT 15) SELF
- JOIN "dict"."vw_dict_country" AS "countries" ON countries.id = SELF.country
- LEFT JOIN "dict"."vw_dict_resort_place" AS "resort_place" ON resort_place.id = SELF.resort_place
- LEFT JOIN "dict"."vw_dict_alloccat" AS "alloccats" ON alloccats.id = SELF.cat
- LEFT JOIN "lsh"."lsh_hotel_like_info" AS "likes" ON likes.allocation_id = SELF.id
- LEFT JOIN "dict"."vw_dict_allocation_type" AS "at" ON at.id = SELF.allocation_type
- LEFT JOIN "dict"."vw_dict_rel_alloc_place_value" AS "rapv" ON rapv.allocation = SELF.id
- LEFT JOIN "dict"."vw_dict_alloc_place_value" AS "alpv" ON alpv.id = rapv.place_value
- LEFT JOIN "dict"."vw_dict_alloc_place_type" AS "apt" ON apt.id = alpv.place
- LEFT JOIN "dict"."th_allocation_stat" AS "ap" ON ap.allocation_id = SELF.id
- GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
- ORDER BY recomended DESC, rate DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement