row_number() over (ORDER BY sum(CASE WHEN eor.type = 'on' THEN cast(datediff(minute, eor.start_time,eor.end_time)*1.0/60 as decimal(10,2)) ELSE null END )/sum(CASE WHEN type = 'off' THEN 1 ELSE 0 END) DESC) AS serialNumber,
eor.equipment_code AS equipmentCode,
sum(CASE WHEN eor.type = 'on' THEN cast(datediff(minute, eor.start_time,eor.end_time)*1.0/60 as decimal(10,2)) ELSE null END ) AS onTime,
sum(CASE WHEN eor.type = 'off' THEN 1 ELSE 0 END) AS shutDownNumber,
cast(sum(CASE WHEN eor.type = 'on' THEN datediff(minute, eor.start_time,eor.end_time)*1.0/60 ELSE null END )/sum(CASE WHEN type = 'off' THEN 1 ELSE 0 END)as decimal(10,2)) as mtbf
from equ_operation_record eor
left join base_equipment be on eor.equipment_code = be.equipment_code