Guest User

Untitled

a guest
Nov 14th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. CREATE VIEW rep_ops_first_ap_offer as (
  2. SELECT
  3. ap.id "ap_id",
  4. ao.id "offer_id",
  5. ifnull(ap.first_offer_published_at, min(ao.published_at)) "published_date",
  6. ao.created_source,
  7. ao.created_by_type,
  8. IF(pp.created_by = 'c4f8a449-e69e-484a-a277-939b0a1a1e63',1,0) "old_ss",
  9. count(distinct ao.id) "total_offers",
  10. p.address_city_code "city",
  11. bs.score
  12.  
  13.  
  14. FROM prod_reporting.accommodation_offer ao
  15. LEFT JOIN prod_reporting.property AS p ON p.id = ao.property_id
  16. LEFT JOIN prod_reporting.accommodation_provider AS ap ON ap.id = p.accommodation_provider_id
  17. LEFT JOIN prod_reporting.prospective_property pp ON p.id = pp.id
  18. LEFT JOIN prod_reporting_ops.rep_ops_ac_bookable_supply AS bs ON bs.offer_id = ao.id
  19.  
  20. WHERE ap.is_test = 0
  21. AND ao.published_at is not null
  22. GROUP BY ap.id);
Add Comment
Please, Sign In to add comment