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

  • 相关阅读:
    论文-Deep Residual Learning for Image Recognition
    网易2017秋招编程题集合-牛客网
    论文-GoogleNet : Going Deeper with Convolutions
    腾讯2016研发工程师编程题-牛客网
    网易2017春招笔试真题编程题集合-牛客网
    剑指offer-把二叉树打印成多行
    剑指offer-翻转单词顺序列
    剑指offer-和为S的连续正数序列
    Java [leetcode 21]Merge Two Sorted Lists
    Java [leetcode 20]Valid Parentheses
  • 原文地址:https://www.cnblogs.com/cdcr/p/9438011.html
Copyright © 2011-2022 走看看