YZ_MES/报表sql/Excel/BatchNoResistivity_[excel].sql

42 lines
1.3 KiB
SQL

select
order_no ,
resistivity ,
min ,
case
when min >= 1.9 then '高阻'
else '低阻'
end
from
(
select
order_no ,
resistivity,
case
when resistivity like '>%' then SUBSTRING(resistivity, 5, 7)
when resistivity like '%~%' then SUBSTRING_INDEX(resistivity, '~', 1)
when resistivity like '%-%' then SUBSTRING_INDEX(resistivity, '-', 1)
when resistivity like '<%' then SUBSTRING(resistivity, 5, 7)
when resistivity like '>%' then SUBSTRING(resistivity, 2, 7)
when resistivity like '<%' then SUBSTRING(resistivity, 2, 7)
when resistivity = '未分档'
or resistivity is null then '未分档'
end min
from
mes_sync.mes_recycle_material_storage mrms
union
select
order_no ,
resistivity,
case
when resistivity like '&gt;%' then SUBSTRING(resistivity, 5, 7)
when resistivity like '%~%' then SUBSTRING_INDEX(resistivity, '~', 1)
when resistivity like '%-%' then SUBSTRING_INDEX(resistivity, '-', 1)
when resistivity like '&lt;%' then SUBSTRING(resistivity, 5, 7)
when resistivity like '>%' then SUBSTRING(resistivity, 2, 7)
when resistivity like '<%' then SUBSTRING(resistivity, 2, 7)
when resistivity = '未分档'
or resistivity is null then '未分档'
end
from
mes_sync.mes_disposable_qc_task
)a