select
val1.serial_no beanKey, val1.fail beanValNeed, val2.total beanValTotal from ( select count(guid) fail , serial_no from `sqm`.`sqm_value_quality_station` WHERE result='1' GROUP BY serial_no ) val1 left join ( select count(guid) total, serial_no from `sqm`.`sqm_value_quality_station` GROUP BY serial_no ) val2 on val1.serial_no = val2.serial_no
select
val1.serial_no beanKey, val1.station, val1.fail beanValNeed, val2.total beanValTotal from ( select count(guid) fail , serial_no, station from `sqm`.`sqm_value_quality_station` WHERE result='1' GROUP BY serial_no ) val1 left join ( select count(guid) total, serial_no from `sqm`.`sqm_value_quality_station` GROUP BY serial_no ) val2 on val1.serial_no = val2.serial_no
select
val1.serial_no SN, val1.station Station, val1.fail beanValNeed, val2.total beanValTotal from ( select count(guid) fail , serial_no, station from `sqm`.`sqm_value_quality_station` WHERE result='1' GROUP BY station ) val1 left join ( select count(guid) total, serial_no, station from `sqm`.`sqm_value_quality_station` GROUP BY station ) val2 on val1.station = val2.stationselect * from `sqm`.`sqm_alarm` where createtime in( select min(createtime) from `sqm`.`sqm_alarm` group by type)