Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
892 B
5
Indexable
select distinct pn.region_name, s.name,m.miss_station_id, m.station_id, m.miss_scan_bag_session_id,m.bag_order,m.miss_type, m.related_bag_order, u.username,m.thexam_1user ,m.reason,m.n_user,m.code,
      m.his_truck_created scan_1, m.next_his_truck_created scan_2, m.created miss_time_refer --m.next_station_id, m.next_scan_bag_session_id,
from test.thangnm64_fault_imex_liable_user m 
left join test.sgw_lego_station sls on sls.station_id = m.miss_station_id and sls.is_hub = 1
inner join ghtk.stations s on m.miss_station_id = s.id and (s.trf_level = 'kho_tong' or sls.is_hub = 1) and s.name not iregexp 'Sân Bay'
left join ghtk_view_ba.provinces_with_region_name pn on pn.id = s.province_id
left join ghtk.users u on m.user_id= u.id
where m.working_month_key=working_month_key(${ts_N_01=yyyyMMdd}) and trunc(his_truck_created,'DD')='${ts_N_01_yyyy_mm_dd}' and n_user is not null
limit 49;