select * from (
select c.OrderNumber ,
c.Name as equipmentName,
a.*,
d.Starttime, d.Endtime,
( select datediff(d.Starttime, d.Endtime)) as Lev ,
case ( select datediff(d.Starttime, d.Endtime))
when ( select datediff(d.Starttime, d.Endtime)) <=10 then '紧急维修'
when 10<( select datediff(d.Starttime, d.Endtime))<=30 then '预计维修'
else '无需维修' end as LevName
from cloud_componentlist a
left join
cloud_equipmentcomponen b on a.Id= b.component
left join cloud_equipment c on c.EquipmentId = b.EquipmentId
left join (select * from cloud_componentrepairrecord limit 0, 1 order by CreateDate desc ) d
on d.Cloud_componentId= a.Id where 1=1 order by Lev desc ) a limit 0,10;