zoukankan      html  css  js  c++  java
  • mysql函数

    DROP FUNCTION IF EXISTS `getOpPassRate`;
    DELIMITER ;;
    CREATE  FUNCTION `getOpPassRate`(batchNo varchar(200) , opUrl varchar(200)) RETURNS varchar(200) CHARSET utf8
    BEGIN
    DECLARE opPassRateStr varchar(200);
    DECLARE opPassRate decimal(16,8);
    IF opUrl = 'JR'
        THEN set opPassRate = (select count(1) from TT_WO_NAKED_CELL twnc where twnc.BATCH_NO = batchNo and twnc.DEL_FLAG != '1')/((select count(1) from TT_WO_NAKED_CELL twnc where twnc.BATCH_NO = batchNo and twnc.DEL_FLAG != '1') + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'RK'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.RK_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.RK_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'DGHJ'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.DGHJ_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.DGHJ_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'DXHK'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.DXHK_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.DXHK_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'YCZY'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.YCZY_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.YCZY_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'HC'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.HC_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.HC_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'ECZY'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.ECZY_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.ECZY_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSEIF opUrl = 'FR'
        THEN set opPassRate = (select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.FR_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a)/((select count(1) from (select twc.CELL_CODE from tt_wo_cell twc where twc.FR_EQUIP_CODE is not null and twc.DEL_FLAG != '1' group by twc.CELL_CODE) a) + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    ELSE
    set opPassRate = (select sum(tww.FINISH_QTY) from tt_wo_wip tww where tww.BATCH_NO = batchNo and tww.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and tww.DEL_FLAG != '1')/((select sum(tww.FINISH_QTY) from tt_wo_wip tww where tww.BATCH_NO = batchNo and tww.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and tww.DEL_FLAG != '1') + (select sum(twbs.SCRAP_QTY) from tt_wo_batch_scrap twbs where twbs.BATCH_NO = batchNo and twbs.OP_ID = (select top.PK_ID from tm_operation top where top.OPERATE_URL = opUrl) and twbs.DEL_FLAG != '1'));
    END IF;
    IF opPassRate is not null
        then set opPassRateStr = FORMAT(opPassRate*100,2);
    END IF;
    RETURN opPassRateStr;
    END
    ;;

  • 相关阅读:
    JVM
    Java反射和动态代理
    JMS(Java消息服务)
    Java多线程及并发
    zookeeper集群自动启动脚本
    zookeeper命令行客户端
    Zookeeper集群搭建步骤及相关知识点深入了解
    MySQL server PID file could not be found!
    Linux下jdk、Tomcat、MySQL的安装
    修改Linux的基本配置
  • 原文地址:https://www.cnblogs.com/cdcr/p/9438011.html
Copyright © 2011-2022 走看看