Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.5 kB
0
Indexable
Never
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 "SmRestaurant" restaurant 
left join "Contact" createdby
    on createdby."Id"  = restaurant."CreatedById" 
left join "Contact" modifiedby
    on modifiedby."Id" = restaurant."ModifiedById"
left join "Contact" agent
    on agent."Id" = restaurant."SmAgentId" 
left join "City" city
    on city."Id" = restaurant."SmCityId" 
left join "SysAdminUnit" division
    on division."Id" = restaurant."SmDivisionId" 
left join "Contact" rest_owner
    on rest_owner."Id" = restaurant."SmOwnerId" 
left join "SmRestaurantReactivationRejectReason" reject_reason
    on reject_reason."Id" = restaurant."SmReactivationRejectReasonId" 
left join "SmRestaurantReactivationStatus" reactivation_status
    on reactivation_status."Id" = restaurant."SmReactivationStatusId" 
left join "SmRestaurantReactivationRejectReason" termination_reason
    on termination_reason."Id" = restaurant."SmTerminationReasonId" 
left join "SmRestaurantStatus" rest_status
    on rest_status."Id" = restaurant."SmStatusId" 
left join "Contact" owner_activation
    on owner_activation."Id" = restaurant."SmOwnerActivationId" 
left join "Contact" owner_reactivation
    on owner_reactivation."Id" = restaurant."SmOwnerReactivationId" 
left join "ActivityStatus" activity_status
    on activity_status."Id" = restaurant."SmActivityStatusId" 
left join "SmTypeFunnelRestaurant" funnel_restaurant
    on funnel_restaurant."Id" = restaurant."SmTypeFunnelRestId" 
Leave a Comment