mount

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

  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.station

 


select * from
`sqm`.`sqm_alarm`
where createtime
in
( select min(createtime)  from `sqm`.`sqm_alarm` group by  type) 

posted on 2011-11-22 09:04  http://guoyinfeng.info/  阅读(113)  评论(0编辑  收藏  举报