insert table cdata_safe_income_new_day_analysis_item_status with t1 as ( select if(a.app_id is null,b.app_id,a.app_id) as app_id, if(a.product is null,b.product,a.product) as product, if(a.item_code_name is null,b.item_code_name,a.item_code_name) as item_code_name, case when a.app_id is null and (if(a.tiaozhang_cnt is null,0,a.tiaozhang_cnt) + if(b.tiaozhang_cnt is null,0,b.tiaozhang_cnt)) > 0 then '调账影响' when b.app_id is null and (if(a.tiaozhang_cnt is null,0,a.tiaozhang_cnt) + if(b.tiaozhang_cnt is null,0,b.tiaozhang_cnt)) > 0 then '调账影响' when a.app_id is null and (if(a.tuifei_cnt is null,0,a.tuifei_cnt) + if(b.tuifei_cnt is null,0,b.tuifei_cnt)) > 0 then '退费影响' when b.app_id is null and (if(a.tuifei_cnt is null,0,a.tuifei_cnt) + if(b.tuifei_cnt is null,0,b.tuifei_cnt)) > 0 then '退费影响' when a.app_id is null and c.voucher_begin > 0 then '优惠券影响' --- 原:续费使用了代金券 when a.app_id is null and c.voucher_end > 0 and change_order_cnt = 0 then '优惠券影响' --- 原:续费使用了代金券 when b.app_id is null and c.voucher_begin > 0 then '优惠券影响' --- 原:续费由代金券转为正常 when b.app_id is null and c.voucher_end > 0 and change_order_cnt = 0 then '优惠券影响' --- 原:续费由代金券转为正常 else 'item维度正常' end flag_status from (select app_id, product,item_code_name,sum(if(paymode_type = '调账',1,0)) as tiaozhang_cnt, sum(if(instr(paymode,'退费')>0,1,0)) as tuifei_cnt from cdata_safe_income_new_day where ftime = '${YYYYMMDD}' and paymode != '0元订单' and prod_class1_name = '基础安全' and prod_class2_name = '云原生安全' and product is not null and pay_type = '公有云' group by app_id,product,item_code_name ) a full join

时间: 2024-02-15 18:19:39 浏览: 159
RAR

Cdata-structure.rar_visual c

(select app_id, product,item_code_name,sum(if(paymode_type = '调账',1,0)) as tiaozhang_cnt, sum(if(instr(paymode,'退费')>0,1,0)) as tuifei_cnt from cdata_safe_income_new_day where ftime = '${YYYYMMDD}' and paymode != '0元订单' and prod_class1_name = '基础安全' and prod_class2_name = '云原生安全' and product is not null and pay_type = '公有云' group by app_id,product,item_code_name ) b on a.app_id = b.app_id and a.product = b.product and a.item_code_name = b.item_code_name left join (select app_id, product,item_code_name, sum(if(instr(paymode,'优惠')>0,1,0)) as voucher_begin, sum(if(instr(paymode,'优惠')>0,1,0)) as voucher_end, sum(if(change_order_cnt > 0,1,0)) as change_order_cnt from cdata_safe_income_new_day where ftime = '${YYYYMMDD}' and paymode != '0元订单' and prod_class1_name = '基础安全' and prod_class2_name = '云原生安全' and product is not null and pay_type = '公有云' group by app_id,product,item_code_name) c on a.app_id = c.app_id and a.product = c.product and a.item_code_name = c.item_code_name; commit;
阅读全文

相关推荐

以下sql存在多条一样的general_master_type_nm数据,怎么修改呢? WITH -- 表示権限区分が0の汎用マスタ区分を洗い出す a1 AS ( SELECT DISTINCT GENERAL_MASTER_TYPE, DISPLAY_AUTH_CLS AS displayAuthCls FROM m_general WHERE DISPLAY_AUTH_CLS = '0' ), -- 更新権限区分が0の汎用マスタ区分を洗い出す a2 AS ( SELECT DISTINCT GENERAL_MASTER_TYPE, UPD_AUTH_CLS AS updAuthCls FROM m_general WHERE UPD_AUTH_CLS = '0' ), b AS ( SELECT GENERAL_MASTER_TYPE, GENERAL_MASTER_TYPE_NM, MIN( DISPLAY_AUTH_CLS ) AS displayAuthCls, MIN( UPD_AUTH_CLS ) AS updAuthCls FROM m_general GROUP BY GENERAL_MASTER_TYPE, GENERAL_MASTER_TYPE_NM ),-- a と bを合併した最小表示権限区分 c AS ( SELECT b.GENERAL_MASTER_TYPE, b.GENERAL_MASTER_TYPE_NM, IFNULL ( a1.displayAuthCls, b.displayAuthCls ) AS displayAuthCls, IFNULL ( a2.updAuthCls, b.updAuthCls ) AS updAuthCls FROM b LEFT JOIN a1 ON b.GENERAL_MASTER_TYPE = a1.GENERAL_MASTER_TYPE LEFT JOIN a2 ON b.GENERAL_MASTER_TYPE = a2.GENERAL_MASTER_TYPE ) -- 抽出結果 SELECT DISTINCT (mg.GENERAL_MASTER_TYPE), mg.GENERAL_MASTER_TYPE_NM, c.updAuthCls, c.displayAuthCls, #{authority.slpmAuthCls} as slpmAuthCls FROM m_general mg INNER JOIN c ON mg.GENERAL_MASTER_TYPE = c.GENERAL_MASTER_TYPE AND (c.displayAuthCls <![CDATA[ <> '0']]> OR ( #{authority.slpmAuthCls} = '0' AND #{authority.levelType} ='1') ) WHERE 1 = 1 <if test="!containsDel"> and mg.del_flg <![CDATA[ <> '1']]> </if> ORDER BY mg.GENERAL_MASTER_TYPE_NM ASC </select>

(random.randint(0, bs_data[12]-1))*3+bs_data[8] 报错:Traceback (most recent call last): File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3652, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 12 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 128, in <module> data = optimizing() File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 15, in __init__ self.optimizing_main() File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 124, in optimizing_main self.child2=self.mutation_cdata(fitness_data,self.cross_data) File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 92, in mutation_cdata print('cross_data[波束场景No]',bs_data[12]) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 3761, in __getitem__ indexer = self.columns.get_loc(key) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc raise KeyError(key) from err KeyError: 12