erwr

  create table yyfx.ljt_1_cnt as
    SELECT COUNT(CASE
             WHEN B.WRITEOFF_FEE_NONCASH > (A.MONTH_FEE * 0.5) THEN
              T.USER_NO
           END) USER_NONCASH_50
    FROM (SELECT /*+PARALLEL(T,4)*/
             T.USER_NO,
             T.AREA_NO,
             T.AREA_NAME,
             T.CITY_NO,
             T.CITY_NAME,
             T.CHANNEL_CLASS,
             T.CHANNEL_CLASS_NAME,
             T.HY_TYPE,
             T.HY_TYPE_NAME,
             T.PRODUCT_ID,
             T.ASSURE_TYPE
              FROM MID.MID_M_UE_G3_FLAG T
             WHERE T.ACCT_MONTH = '201309'
               AND T.USER_TYPE_CODE <> '1') T,
           (SELECT PRODUCT_ID, A.MONTH_FEE, A.DINNER_TYPE_ID
              FROM KPICODE.KPICODE_PRODUCT A
             WHERE FLAG <> '1'
               AND A.DINNER_TYPE_ID NOT IN ('0504', '0505')) A,
           ( SELECT /*+PARALLEL(B,4)*/
     B.USER_ID,
     SUM(CASE
           WHEN C.DEPOSIT_TYPE_CODE IN ('0', '1') THEN
            B.WRITEOFF_FEE
           ELSE
            0
         END) WRITEOFF_FEE_CASH,
     SUM(CASE
           WHEN C.DEPOSIT_TYPE_CODE IN ('2', '3') THEN
            B.WRITEOFF_FEE
           ELSE
            0
         END) WRITEOFF_FEE_NONCASH
      FROM (SELECT /*+PARALLEL(B,4)*/
             B.USER_ID,
             B.DEPOSIT_CODE,
             SUM(NVL(B.WRITEOFF_FEE, 0) / 100) WRITEOFF_FEE
              FROM ODSBI.TF_B_WRITEOFFLOG B
             WHERE B.MONTH_ID = '201309'
               AND B.NET_TYPE_CODE = '33'
             GROUP BY B.USER_ID, B.DEPOSIT_CODE) B,
           (SELECT DEPOSIT_CODE, C.DEPOSIT_NAME, C.DEPOSIT_TYPE_CODE
              FROM STAGE.TD_B_DEPOSIT C
             WHERE DEPOSIT_TYPE_CODE = '2' ---目前口径只取 2 的
               AND DAY_ID = '20131103') C
     WHERE B.DEPOSIT_CODE = C.DEPOSIT_CODE
     GROUP BY B.USER_ID) B  
     WHERE T.USER_NO = B.USER_ID
       AND T.PRODUCT_ID = A.PRODUCT_ID


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值