Untitled

 avatar
unknown
sql
a year ago
3.6 kB
5
Indexable
select
createdby.name as created_by,
restaurant.createdon + interval '3 hours' created_on,
modifiedby.name as modified_by,
restaurant.modifiedon + interval '3 hours' as modified_on,
restaurant.smaccountid as account_identificator,
restaurant.smaccountbillinginfoid as billing_identificator,
restaurant.smactivationdate as activation_date,
restaurant.smaddress as address,
restaurant.smaddresshowto as address_how_to,
restaurant.smaddresslat as lat,
restaurant.smaddresslon as lon,
agent.name as agent,
restaurant.smbrandid as brand_identificator,
city.name as city,
restaurant.smcode as code,
division.name as division,
restaurant.smemail as mail,
restaurant.smexternalcode as external_code,
restaurant.smexternalid as external_id,
restaurant.smname as name,
restaurant.smopportunityid as opportunity_identificator,
rest_owner.name as "owner",
restaurant.smrating as rating,
reject_reason.name as reject_reason,
reactivation_status.name as reactivation_status,
restaurant.smreactivationterm as reactivation_term,
restaurant.smreactivationdate as reactivation_date,
restaurant.smreactivationrejectreasoncomment as reactivation_reject_reason_comment,
termination_reason.name as termination_reason,
restaurant.smterminationreasoncomment as termination_reason_comment,
restaurant.smmap2gispageid as map_2gis_page_id,
restaurant.smmap2gisaccountid as map_2gis_account_id,
restaurant.smmap2gisrating as map_2gis_rating,
restaurant.smmap2gisfeedbackcnt map_2gis_feedback_count,
restaurant.smmapyandexpageid as yandex_page_id,
restaurant.smemaillk as email_lk,
restaurant.smphone as phone,
rest_status.name as status,
restaurant.smstatuscomment as status_comment,
restaurant.smworkschedule as work_schedule,
restaurant.id as identificator,
owner_activation.name as owner_activation,
owner_reactivation.name as owner_reactivation,
activity_status.name as activity_status,
funnel_restaurant.name as funnel_rest_type,
restaurant.smisbillinginfomanualcontrol as billing_info_manual_control
from vw_ods_bpm_soft.vw_smrestaurant restaurant
left join vw_ods_bpm_soft.vw_contact createdby
    on createdby.id  = restaurant.createdbyid
left join vw_ods_bpm_soft.vw_contact modifiedby
    on modifiedby.id = restaurant.modifiedbyid
left join vw_ods_bpm_soft.vw_contact agent
    on agent.id = restaurant.smagentid
left join vw_ods_bpm_soft.vw_city city
    on city.id = restaurant.smcityid
left join vw_ods_bpm_soft.vw_sysadminunit division
    on division.id = restaurant.smdivisionid
left join vw_ods_bpm_soft.vw_contact rest_owner
    on rest_owner.id = restaurant.smownerid
left join vw_ods_bpm_soft.vw_smrestaurantreactivationrejectreason reject_reason
    on reject_reason.id = restaurant.smreactivationrejectreasonid
left join vw_ods_bpm_soft.vw_smrestaurantreactivationstatus reactivation_status
    on reactivation_status.id = restaurant.smreactivationstatusid
left join vw_ods_bpm_soft.vw_smrestaurantreactivationrejectreason termination_reason
    on termination_reason.id = restaurant.smterminationreasonid
left join vw_ods_bpm_soft.vw_smrestaurantstatus rest_status
    on rest_status.id = restaurant.smstatusid
left join vw_ods_bpm_soft.vw_contact owner_activation
    on owner_activation.id = restaurant.smowneractivationid
left join vw_ods_bpm_soft.vw_contact owner_reactivation
    on owner_reactivation.id = restaurant.smownerreactivationid
left join vw_ods_bpm_soft.vw_activitystatus activity_status
    on activity_status.id = restaurant.smactivitystatusid
left join vw_ods_bpm_soft.vw_smtypefunnelrestaurant funnel_restaurant
    on funnel_restaurant.id = restaurant.smtypefunnelrestid;
    
Editor is loading...
Leave a Comment