连续重复10次以上

select 
     main_body
    ,flow_out_cust_code        -- 流入方编码  
    ,flow_out_cust_name        -- 
    ,detail_convert_quantity     --
    ,minus_id_rank
    ,count(1)
from 
(select
     main_body
    ,flow_out_cust_code        -- 流入方编码  
    ,flow_out_cust_name        -- 
    ,detail_convert_quantity     -- 
    ,row_number() over(order by main_body,flow_out_cust_code,flow_out_cust_name,flow_dt) id_new
    ,row_number() over(partition by detail_convert_quantity order by main_body,flow_out_cust_code,flow_out_cust_name,flow_dt asc) num_rank
    ,row_number() over(order by main_body,flow_out_cust_code,flow_out_cust_name,flow_dt) - row_number() over(partition by detail_convert_quantity order by main_body,flow_out_cust_code,flow_out_cust_name,flow_dt asc) minus_id_rank
from  jmkx_data.ads_yxzx_netsale_op_cxm_dd a
where a.dt = (select max(dt) from jmkx_data.ads_yxzx_netsale_op_cxm_dd)
  and a.cfy_classify5 in ('金水宝','金水宝片')
  and case when day(date_add(current_date(),-1))<=14 then flow_dt< trunc(date_add(current_date(),-1),'MM') else 1=1 end  --14号定版
) tmp 
group by 
     main_body
    ,flow_out_cust_code        -- 流入方编码  
    ,flow_out_cust_name        -- 
    ,detail_convert_quantity     --
    ,minus_id_rank
having count(1)>10

你可能感兴趣的:(java,前端,javascript)