zoukankan      html  css  js  c++  java
  • mysql procedure

    DELIMITER //
      CREATE PROCEDURE in_param(IN motherfuckerA VARCHAR(31),IN motherfuckerB VARCHAR(31))
        BEGIN
        SELECT a.bid,SUM(a.signingNumber),SUM(a.testNumber) FROM 
        (
                SELECT ce.bid,COUNT(ce.cid) signingNumber,NULL testNumber FROM
                (
                    SELECT b.id bid,cus.id cid,cus.creat_time,cus.large_area_code FROM  
                        (
                            SELECT c.id,c.creat_time,c.large_area_code,c.accendant_id FROM customer c  WHERE c.`status` = 'SUCCESS' AND c.account_type = 'SIGNING' 
                        ) cus 
                    RIGHT JOIN sys_emplyee b ON cus.accendant_id = b.id
                    WHERE cus.large_area_code IN (motherfuckerA)
                ) ce GROUP BY ce.bid
        UNION ALL
        
                SELECT ce.bid,NULL signingNumber, COUNT(ce.cid) testNumber FROM 
                (
                    SELECT b.id bid,cus.id cid,cus.creat_time,cus.large_area_code FROM  
                    (
                        SELECT c.id,c.creat_time,c.large_area_code,c.accendant_id FROM customer c WHERE c.`status` = 'SUCCESS' AND c.account_type = 'TEST' 
                    ) cus
                    RIGHT JOIN sys_emplyee b ON  cus.accendant_id = b.id
                    WHERE cus.large_area_code IN (motherfuckerB)
                ) ce 
                GROUP BY ce.bid
        ) a GROUP BY a.bid;
        END;
        //
    DELIMITER ;
        
    SET @motherfuckerA='southwestRegion';
    SET @motherfuckerB='southRegion';
    CALL in_param(@motherfuckerA,@motherfuckerB)
  • 相关阅读:
    js对象数组中的某属性值 拼接成字符串
    mongodb 简单的增删改查
    celery简单使用
    Redis简单操作
    三大认证源码分析
    认证、权限、频率、自定义签发token-多方式登录
    jwt认证
    视图家族
    day75作业
    day74作业
  • 原文地址:https://www.cnblogs.com/gandefeng/p/10734839.html
Copyright © 2011-2022 走看看