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
    ;;

  • 相关阅读:
    【STM32F407的DSP教程】第4章 Matlab简易使用之脚本文件
    【STM32H7的DSP教程】第3章 Matlab简易使用之基础操作
    【STM32F429的DSP教程】第3章 Matlab简易使用之基础操作
    【STM32F407的DSP教程】第3章 Matlab简易使用之基础操作
    【STM32H7的DSP教程】第2章 Matlab R2018a的安装
    【STM32F429的DSP教程】第2章 Matlab R2018a的安装
    【STM32F407的DSP教程】第2章 Matlab R2018a的安装
    【STM32H7的DSP教程】第1章 初学数字信号处理准备工作
    【STM32F429的DSP教程】第1章 初学数字信号处理准备工作
    【STM32F407的DSP教程】第1章 初学数字信号处理准备工作
  • 原文地址:https://www.cnblogs.com/cdcr/p/9438011.html
Copyright © 2011-2022 走看看