AnandSAA

Untitled

Sep 26th, 2019
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. select
  2. profile.id as profile_id,
  3. profile.name as profile_name,
  4. location_id.value as location_id,
  5. if( location.country_id = location.id, null, area.name ) as area_name,
  6. region.name as region_name,
  7. if( location.country_id = location.id, area.name, country.name ) as country_name
  8. from
  9. b_sale_user_props profile
  10. inner join b_sale_person_type person on person.active='Y'
  11. inner join b_sale_order_props prop on prop.code='location' and prop.person_type_id=person.id
  12. inner join b_sale_user_props_value location_id on location_id.user_props_id=profile.ID and location_id.order_props_id=prop.id
  13. inner join b_sale_location location on location.id=location_id.value
  14. inner join b_sale_loc_name area on area.language_id='en' and area.location_id=location.id
  15. left join b_sale_loc_name region on region.language_id='en' and region.location_id=location.region_id
  16. left join b_sale_loc_name country on country.language_id='en' and country.location_id=location.country_id and location.country_id != location.id
  17. where
  18. profile.user_id=24053
  19. and person.lid='s1'
  20. order by
  21. country_name asc,
  22. region_name asc,
  23. area_name asc
Advertisement
Add Comment
Please, Sign In to add comment