zoukankan      html  css  js  c++  java
  • mysql实践1

      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) 

  • 相关阅读:
    Markdown学习
    二叉树的最近公共祖先
    javaCompiler简析
    自定义类加载器
    聚合和组合的区别
    拓扑排序
    C++ map和unordered_map
    静态文件加载路径
    文件上传
    jackson
  • 原文地址:https://www.cnblogs.com/mount/p/2258308.html
Copyright © 2011-2022 走看看