1. 程式人生 > >sql的執行順序,外連線注意點

sql的執行順序,外連線注意點

select
  date(oi.pay_time)            as event_date,
  count(distinct oi.device_id) as uv,
  count(*)                     as order_total,
  (select platform
   from app_event_log_start_up as su
   where su.uid = oi.user_id
         and date(su.event_time) = '$day'
   limit 1)                    as os,
  pol.user_id
from order_info oi
  left join points_ops_log pol on pol.user_id = oi.user_id
                                  and date(pol.create_time) = '$day'
                                  and pol.ops = 'obtain'
                                  and pol.worker in ('xx', 'xx', 'xx')
where date(oi.pay_time) = '$day'
      and pol.user_id is null
group by os
having os is not null;