decode和instr的用法 以及 row_number() over语法

本文详细介绍了一种复杂的SQL查询技巧,包括使用row_number()进行结果集分区排序、DECODE函数进行条件判断以及instr函数进行字符串定位等高级用法,旨在帮助读者理解和掌握这些SQL技巧。

select operation_type,nename,resource_name,num,rn
from
(
    select nename,operation_type,resource_name,num,row_number() over (partition by operation_type order by num desc) rn
    from
    (
         select operation_type,substr(nename,1,decode(instr(nename,':'),0,length(nename),instr(nename,':')-1)) as nename, resource_name,sum(CRITICAL_NUM)+sum(MAJOR_NUM)+sum(MINOR_NUM) as num
         from ACTIVE_HISTORY_ST
         where operation_type  in('GPRS','MMS') 

                    and trunc(st_date ,'MM') = to_date('2010-10','yyyy-mm')
         group by operation_type,resource_name,nename
    ) a
)b
where rn <=20
order by operation_type,rn

 

row_number() over语法:
row_number() over (partition by col1 order by col2 desc) 别名

作用:返回结果集分区内行的序列号,每个分区的第一行从 1 开始。
表示按照col1分组,在分组内按照col2排序
别名表示每组内部排序后的顺序编号

DECODE的语法:
DECODE(value,if1,then1,if2,then2,if3,then3,...,else),表示如果value等于if1时,DECODE函数的结果返回then1,...,如果不等于任何一个if值,则返回else。

 

instr的语法:
instr(string1,string2[,start_position[,nth_appearane]])
string1:源字符串,要在此字符串中查找
string2:要在string1中查找的字符串
start_position:代表string1的哪个位置开始查找。可选参数,默认为1,若参数为正,表示从左到右开始检索,反之从右到左检索。返回要查找的字符串在源字符串中的开始索引
nth_appearance:代表要查找第几次出现的string2,可选参数,默认为1。不允许为负数
注意:若string2在string1中没有找到,则instr函数返回0

<select id="getValuationSummary" parameterType="com.hundsun.amos.queryrpt.api.bean.AssetValueDTO" resultMap="BaseAssetResultMap"> select * from (with email as (select ff.fund_code, ff.fund_id, <if test="isPpos"> a.DATA_SOURCE, a.publish_rate, a.publish_state, a.ACTIVE_VERIFYRATE, </if> ff.service_type, ff.FUND_TYPE, ff.TRANSACTION_SERVICE_TYPE, apex.FUND_ORIGIN_INFO, apex.SETTLEMENT_MODE, ff.NON_STANDARD_PDT, ff.SPECIAL_RISK_TYPE from amos_pdt_fundinfo ff <if test="isToasseessment"> right join AMOS_TOASSESSMENT_M atm on ff.fund_code=atm.FUND_CODE </if> inner join AMOS_BASE_FUNDAUTHDETAL auth on ff.fund_id = auth.fund_id inner join AMOS_PDT_FUNDINFOEX apex on ff.fund_id = apex.fund_id <if test="isPpos"> left join ( select s.DATA_SOURCE,s.publish_rate,s.publish_state,s.fund_id,s.ACTIVE_VERIFYRATE from AMOS_QYRPT_VALUATIONSET s where not exists (select 1 from (select fund_id from AMOS_QYRPT_VALUATIONSET group by fund_id having count(1) >1) t where t.fund_id=s.fund_id) union ( select f1.DATA_SOURCE,f1.publish_rate,f1.publish_state,f1.fund_id,f1.ACTIVE_VERIFYRATE from (select DATA_SOURCE,publish_rate,fund_id,publish_state,ACTIVE_VERIFYRATE from AMOS_QYRPT_VALUATIONSET where DATA_SOURCE='WB')f1 left join (select DATA_SOURCE,publish_rate,fund_id,publish_state,ACTIVE_VERIFYRATE from AMOS_QYRPT_VALUATIONSET where DATA_SOURCE='TG')f2 on f1.fund_id=f2.fund_id where f2.data_source is not null) )a on ff.fund_id = a.fund_id </if> where 1 = 1 <if test="opeator!=null and opeator!=''"> and auth.user_id=#{opeator} </if> <if test="inputList != null and inputList.size()>0"> and ff.fund_code in <foreach collection="inputList" item="item" index="index" open="(" close=")" separator=","> #{item.vcFundcode} </foreach> </if> <if test="fundType != null and fundType != ''"> AND ff.FUND_TYPE IN <foreach item="item" index="index" collection="fundType.split(',')" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="nonStandardPdt != null and nonStandardPdt != ''"> AND ff.NON_STANDARD_PDT IN <foreach item="item" index="index" collection="nonStandardPdt.split(',')" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="settlementMode != null and settlementMode != ''"> AND apex.settlement_mode IN <foreach item="item" index="index" collection="settlementMode.split(',')" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="serviceType != null and serviceType != ''"> AND <foreach item="item" index="index" collection="serviceType.split(',')" open="(" separator="or" close=")"> instr(ff.service_type, #{item}) > 0 </foreach> </if> <if test="transactionServiceType != null and transactionServiceType != ''"> AND <foreach item="item" index="index" collection="transactionServiceType.split(',')" open="(" separator="or" close=")"> instr(ff.TRANSACTION_SERVICE_TYPE, #{item}) > 0 </foreach> </if> <if test="specialRiskType != null and specialRiskType != ''"> AND <foreach item="item" index="index" collection="specialRiskType.split(',')" open="(" separator="or" close=")"> instr(nvl(ff.SPECIAL_RISK_TYPE, '0'), #{item}) > 0 </foreach> </if> <if test="fundOriginInfo != null and fundOriginInfo != ''"> AND <foreach item="fundOriginInfoItem" index="index" collection="fundOriginInfo.split(',')" open="(" separator="or" close=")"> instr(apex.FUND_ORIGIN_INFO, #{fundOriginInfoItem}) > 0 </foreach> </if> ) <if test="enSjly !='WB'"> select h.vc_glr vc_glr, <include refid="resultSql"/> <if test="isPpos"> nvl(email.publish_rate,'1') plpl, nvl( email.publish_state,'1') plzt, decode(email.publish_rate,'3',email.ACTIVE_VERIFYRATE) actual_check_frequency, nvl(email.ACTIVE_VERIFYRATE, decode(email.publish_rate, '3', least(foe.compare_Freq)) ) sjplpl, </if> '托管估值' en_sjly_name, 'TG' en_sjly, email.FUND_TYPE, email.TRANSACTION_SERVICE_TYPE, email.FUND_ORIGIN_INFO, email.SETTLEMENT_MODE, email.NON_STANDARD_PDT, email.SPECIAL_RISK_TYPE from tgcbs.tjjmrhjsj t inner join email on t.vc_jjdm=email.fund_code and ( INSTR(','||email.SERVICE_TYPE||',',',1,')>0 and INSTR(','||email.SERVICE_TYPE||',',',2,')=0 and INSTR(','||email.SERVICE_TYPE||',',',6,')=0 and instr(','||email.SERVICE_TYPE||',',',7,')=0) <include refid="mfcodeSql"/> left join tgcbs.ttmpgzb_index a on t.l_ztbh = a.l_ztbh and t.d_rq = a.d_ywrq left join (select l_ztbh, l_dzjg , d_begin from (select zb.l_ztbh, zb.l_dzjg, zb.d_begin, row_number() over(partition by zb.l_ztbh, zb.d_begin order by zb.d_scrq desc) rn from tgcbs.tycdz_tgr_zb zb where zb.l_sfbz = 0 <if test="startDate != null and startDate!= '' and endDate!=null and endDate!=''"> and zb.d_begin between to_date(#{startDate},'yyyy-mm-dd') and to_date(#{endDate},'yyyy-mm-dd') </if> <if test="dateRate != null and dateRate!= ''"> <choose> <when test="dateRateWeekMonthFlag != null and dateRateWeekMonthFlag != '' and dateRateWeekMonthFlag == '1'.toString()"> and to_char(zb.d_begin ,'yyyy-MM-dd') IN <foreach collection="dateRateWeekMonthDates" item="item" index="index" open="(" close=")" separator=","> #{item} </foreach> </when> <otherwise> and exists ( <include refid="tradeDateSql1"/> ) </otherwise> </choose> </if> ) where rn = 1) b on t.l_ztbh = b.l_ztbh and b.d_begin=t.d_rq , (select g.vc_mc vc_glrmc, f.vc_glr, f.vc_tgr, f.vc_name, f.l_fundid from tgcbs.tfundinfo f left join tgcbs.tglrxx g on f.vc_glr = g.vc_bh ) h <include refid="filterArgs"/> <if test="isPpos"> and nvl(email.publish_state, '1') in (nvl(a.l_sfqr, 0),'3') <include refid="pposSql"/> </if> </if> <if test="enSjly==null"> union all </if> <if test="enSjly !='TG'"> select h.vc_glrmc vc_glr, <include refid="resultSql"/> <if test="isPpos"> nvl(email.publish_rate,'1') plpl, nvl( email.publish_state,'3') plzt, decode(email.publish_rate,'3',email.ACTIVE_VERIFYRATE) actual_check_frequency, nvl(email.ACTIVE_VERIFYRATE, decode(email.publish_rate, '3', least(foe.compare_Freq)) ) sjplpl, </if> '外包估值' en_sjly_name, 'WB' en_sjly, email.FUND_TYPE, email.TRANSACTION_SERVICE_TYPE, email.FUND_ORIGIN_INFO, email.SETTLEMENT_MODE, email.NON_STANDARD_PDT, email.SPECIAL_RISK_TYPE from hsfa.tjjmrhjsj t inner join email on t.vc_jjdm=email.fund_code and (INSTR(','||email.SERVICE_TYPE||',',',2,')>0 or INSTR(','||email.SERVICE_TYPE||',',',6,')>0 or instr(','||email.SERVICE_TYPE||',',',7,')>0) <include refid="mfcodeSql"/> left join hsfa.ttmpgzb_index a on t.l_ztbh = a.l_ztbh and t.d_rq = a.d_ywrq left join (select l_ztbh, l_dzjg , d_begin from (select zb.l_ztbh, zb.l_dzjg, zb.d_begin, row_number() over(partition by zb.l_ztbh, zb.d_begin order by zb.d_scrq desc) rn from hsfa.tycdz_zb zb where zb.l_sfbz = 0 <if test="startDate != null and startDate!= '' and endDate!=null and endDate!=''"> and zb.d_begin between to_date(#{startDate},'yyyy-mm-dd') and to_date(#{endDate},'yyyy-mm-dd') </if> <if test="dateRate != null and dateRate!= ''"> <choose> <when test="dateRateWeekMonthFlag != null and dateRateWeekMonthFlag != '' and dateRateWeekMonthFlag == '1'.toString()"> and to_char(zb.d_begin ,'yyyy-MM-dd') IN <foreach collection="dateRateWeekMonthDates" item="item" index="index" open="(" close=")" separator=","> #{item} </foreach> </when> <otherwise> and exists ( <include refid="tradeDateSql1"/> ) </otherwise> </choose> </if> ) where rn = 1) b on t.l_ztbh = b.l_ztbh and b.d_begin=t.d_rq , (select g.vc_mc vc_glrmc, f.vc_glr, f.vc_tgr, f.vc_name, f.l_fundid from hsfa.tfundinfo f left join hsfa.tglrxx g on f.vc_glr = g.vc_bh ) h <include refid="filterArgs"/> <if test="isPpos"> and nvl(email.publish_state, '3') in (nvl(a.l_sfqr, 0),'3') <include refid="pposSql"/> </if> </if>) order by d_rq desc </select>换成可测试的
11-29
v_vc_ycbz varchar2(2):= 'Y'; begin return_code:=-99; return_str := '[pkg_dubbo.pkgsp_sp_hsdubbo_new_cxPz]获取凭证表数据失败,请联系系统管理员'; open return_data for /* with v_gzbdate as ( select i.l_ztbh ,i.d_ywrq from tfundinfo t ,ttmpgzb_index i where t.l_fundid = i.l_ztbh and i.l_sfqr = 1 and instr(',' || a_vc_cpdm || ',', ',' || a.vc_code || ',') > 0 and i.d_ywrq >= to_date(a_d_date_b,'yyyy-mm-dd') and i.d_ywrq <= to_date(a_d_date_e,'yyyy-mm-dd') ) , */ with v_pzbpage as ( select t.*,ROW_NUMBER() OVER (order by t.vc_fundname asc , t.d_pzrq desc ,t.vc_pzh asc ) rowno from ( select a.vc_code vc_fundcode, a.vc_name vc_fundname, a.vc_glr vc_glrmc, v.d_make d_pzrq, lpad(v.l_no, 6, 0) vc_pzh, vs.vc_code vc_kmdm, vs.vc_fullname vc_kmmc, vs.VC_DIGEST vc_zy, decode(vs.EN_DEBIT, 0, -1, 1) en_jd, decode(vs.EN_DEBIT, 0, vs.EN_CREDIT, vs.EN_DEBIT) en_je, vs.EN_QUANTITY en_sl, vs.VC_JSBZ vc_currency, vs.EN_FOREIGN EN_YBJE, vs.en_exch EN_HL, nvl((select nvl((select d.vc_item_name from tdictionary d where 10249 = l_dictionary_no and d.c_lemma_item = z.vc_type), z.vc_sm) vc_name from tzdyzzszz z where z.l_ztbh = (select s.l_type from tsysinfo s where s.l_id=vs.l_fundid ) and z.l_bh = v.l_zzgsbh ),'手工凭证' ) vc_pzlb, 1 l_sjly, vs.l_fundid vc_ztbh from tfundinfo a ,tvoucher v, tvouchers vs where instr(',' || a_vc_cpdm || ',', ',' || a.vc_code || ',') > 0 and vs.l_FundID = a.l_fundid and (vs.vc_code like a_vc_kmdm||'%' or a_vc_kmdm is null) and (vs.vc_fullname like '%'||a_vc_kmmc||'%' or a_vc_kmmc is null) and (vs.VC_DIGEST like '%'||a_vc_zy||'%' or a_vc_zy is null) and vs.d_make between a_d_date_b and a_d_date_e and v.d_make between a_d_date_b and a_d_date_e and v.l_fundid = vs.l_fundid and v.l_id = vs.l_mainid and v.L_STATE < 32 union all select a.vc_code vc_fundcode, a.vc_name vc_fundname, a.vc_glr vc_glrmc, v.d_make d_pzrq, lpad(v.l_no, 6, 0) vc_pzh, vs.vc_code vc_kmdm, vs.vc_fullname vc_kmmc, vs.VC_DIGEST vc_zy, decode(vs.EN_DEBIT, 0, -1, 1) en_jd, decode(vs.EN_DEBIT, 0, vs.EN_CREDIT, vs.EN_DEBIT) en_je, vs.EN_QUANTITY en_sl, vs.VC_JSBZ vc_currency, vs.EN_FOREIGN EN_YBJE, vs.en_exch EN_HL, nvl((select nvl((select d.vc_item_name from tdictionary d where 10249 = l_dictionary_no and d.c_lemma_item = z.vc_type), z.vc_sm) vc_name from tzdyzzszz z where z.l_ztbh = (select s.l_type from tsysinfo s where s.l_id=vs.l_fundid ) and z.l_bh = v.l_zzgsbh ),'手工凭证' ) vc_pzlb, 1 l_sjly, vs.l_fundid vc_ztbh from tfundinfo a , t_h_voucher v ,t_h_vouchers vs where instr(',' || a_vc_cpdm || ',', ',' || a.vc_code || ',') > 0 and vs.l_FundID = a.l_fundid and (vs.vc_code like a_vc_kmdm||'%' or a_vc_kmdm is null) and (vs.vc_fullname like '%'||a_vc_kmmc||'%' or a_vc_kmmc is null) and (vs.VC_DIGEST like '%'||a_vc_zy||'%' or a_vc_zy is null) and v.l_fundid = vs.l_fundid and vs.d_make between a_d_date_b and a_d_date_e and v.d_make between a_d_date_b and a_d_date_e and v.l_id = vs.l_mainid and v.L_STATE < 32 ) t --order by t.vc_fundname desc , t.d_pzrq desc ,t.vc_pzh ) select pp.vc_fundcode, pp.vc_fundname, pp.vc_glrmc, pp.d_pzrq, pp.vc_pzh, pp.vc_kmdm, pp.vc_kmmc , pp.vc_zy , pp.en_jd , pp.en_je , pp.en_sl , pp.vc_currency, pp.EN_YBJE , pp.EN_HL , pp.vc_pzlb , pp.l_sjly, pp.vc_ztbh from v_pzbpage pp where pp.rowno>=((a_l_pageno-1)* a_l_pagenum + 1) and pp.rowno<=a_l_pageno*a_l_pagenum ; -- select count(1) into return_recnum from v_pzbpage ; select count(*) into return_totalcount from ( select a.vc_code vc_fundcode, a.vc_name vc_fundname, a.vc_glr vc_glrmc, v.d_make d_pzrq, lpad(v.l_no, 6, 0) vc_pzh, vs.vc_code vc_kmdm, vs.vc_fullname vc_kmmc, vs.VC_DIGEST vc_zy, decode(vs.EN_DEBIT, 0, -1, 1) en_jd, decode(vs.EN_DEBIT, 0, vs.EN_CREDIT, vs.EN_DEBIT) en_je, vs.EN_QUANTITY en_sl, vs.VC_JSBZ vc_currency, vs.EN_FOREIGN EN_YBJE, vs.en_exch EN_HL, nvl((select nvl((select d.vc_item_name from tdictionary d where 10249 = l_dictionary_no and d.c_lemma_item = z.vc_type), z.vc_sm) vc_name from tzdyzzszz z where z.l_ztbh = (select s.l_type from tsysinfo s where s.l_id=vs.l_fundid ) and z.l_bh = v.l_zzgsbh ),'手工凭证' ) vc_pzlb, 1 l_sjly, vs.l_fundid vc_ztbh from tfundinfo a ,tvoucher v, tvouchers vs where instr(',' || a_vc_cpdm || ',', ',' || a.vc_code || ',') > 0 and vs.l_FundID = a.l_fundid and (vs.vc_code like a_vc_kmdm||'%' or a_vc_kmdm is null) and (vs.vc_fullname like '%'||a_vc_kmmc||'%' or a_vc_kmmc is null) and (vs.VC_DIGEST like '%'||a_vc_zy||'%' or a_vc_zy is null) and v.l_fundid = vs.l_fundid and vs.d_make between a_d_date_b and a_d_date_e and v.d_make between a_d_date_b and a_d_date_e and v.l_id = vs.l_mainid and v.L_STATE < 32 union all select a.vc_code vc_fundcode, a.vc_name vc_fundname, a.vc_glr vc_glrmc, v.d_make d_pzrq, lpad(v.l_no, 6, 0) vc_pzh, vs.vc_code vc_kmdm, vs.vc_fullname vc_kmmc, vs.VC_DIGEST vc_zy, decode(vs.EN_DEBIT, 0, -1, 1) en_jd, decode(vs.EN_DEBIT, 0, vs.EN_CREDIT, vs.EN_DEBIT) en_je, vs.EN_QUANTITY en_sl, vs.VC_JSBZ vc_currency, vs.EN_FOREIGN EN_YBJE, vs.en_exch EN_HL, nvl((select nvl((select d.vc_item_name from tdictionary d where 10249 = l_dictionary_no and d.c_lemma_item = z.vc_type), z.vc_sm) vc_name from tzdyzzszz z where z.l_ztbh = (select s.l_type from tsysinfo s where s.l_id=vs.l_fundid ) and z.l_bh = v.l_zzgsbh ),'手工凭证' ) vc_pzlb, 1 l_sjly, vs.l_fundid vc_ztbh from tfundinfo a , t_h_voucher v ,t_h_vouchers vs where instr(',' || a_vc_cpdm || ',', ',' || a.vc_code || ',') > 0 and vs.l_FundID = a.l_fundid and (vs.vc_code like a_vc_kmdm||'%' or a_vc_kmdm is null) and (vs.vc_fullname like '%'||a_vc_kmmc||'%' or a_vc_kmmc is null) and (vs.VC_DIGEST like '%'||a_vc_zy||'%' or a_vc_zy is null) and v.l_fundid = vs.l_fundid and vs.d_make between a_d_date_b and a_d_date_e and v.d_make between a_d_date_b and a_d_date_e and v.l_id = vs.l_mainid and v.L_STATE < 32 ) t ; return_pages :=floor((return_totalcount + a_l_pagenum -1)/ a_l_pagenum ) ; v_vc_ycbz := 'N'; return_code := 0; return_str := '成功执行'; exception when others then --系统自动异常捕捉 if v_vc_ycbz = 'N' then return_code:=-1; return_str := '[pkg_dubbo.pkgsp_sp_hsdubbo_new_cxPz]异常错误:'||chr(13)||sqlerrm; end if; --人为考虑系统异常 if v_vc_ycbz = 'Y' then return_str := return_str||chr(13)||sqlerrm; end if; --人为的制造了异常 if v_vc_ycbz = 'H' then return_str := return_str; end if; end pkgsp_sp_hsdubbo_new_cxPzbPage;返回的return_data里面结构是什么
11-14
select count(0) from (select distinct ALLDATA.FUND_ID, ALLDATA.FUND_CODE, ALLDATA.FUND_NAME, ALLDATA.INST_NAME, ALLDATA.L_ZTBH, ALLDATA.D_RQ, ALLDATA.EN_DWJZ, ALLDATA.EN_ZCJZ, ALLDATA.EN_ZCFE, ALLDATA.L_SFQR, ALLDATA.d_qrsj, ALLDATA.L_WBHDJG, ALLDATA.SEND_MANAGERSTATE, ALLDATA.SEND_TRUSTEESTATE, ALLDATA.VERIFY_MODE, ALLDATA.THEORY_VERIFYRATE, ALLDATA.ACTIVE_VERIFYRATE, ALLDATA.PUBLISH_RATE, ALLDATA.PUBLISH_STATE, ALLDATA.VC_SJLY, ALLDATA.HAND_REASON, ALLDATA.SERVICE_TYPE, ALLDATA.INST_ID, ALLDATA.VC_FJJJDM, ALLDATA.L_JJJB, ALLDATA.D_SCSJ, ALLDATA.EN_LJDWJZ, ALLDATA.FUND_TYPE fundType, ALLDATA.TRANSACTION_SERVICE_TYPE transactionServiceType, ALLDATA.FUND_ORIGIN_INFO fundOriginInfo, ALLDATA.SETTLEMENT_MODE settlementMode, ALLDATA.NON_STANDARD_PDT nonStandardPdt, ALLDATA.SPECIAL_RISK_TYPE specialRiskType FROM ( select F1.FUND_ID, F1.FUND_CODE, F1.FUND_NAME, F6.INST_NAME, NVL(f9.vc_ztdm,f3.L_ZTBH) L_ZTBH, F3.D_RQ D_RQ, cast(F3.EN_DWJZ as decimal(35,16)) EN_DWJZ, F3.EN_ZCJZ, F3.EN_ZCFE, F3.L_SFQR, F3.d_qrsj, nvl(F5.L_WBHDJG,F3.L_WBHDJG) L_WBHDJG, decode(m.FUND_ID,null,0,1) send_managerstate, nvl(F5.SEND_TRUSTEESTATE,0) SEND_TRUSTEESTATE, nvl(F4.VERIFY_MODE,'1') VERIFY_MODE, nvl(F7.COMPARE_FREQ,'1') THEORY_VERIFYRATE, case when instr(','||F1.SERVICE_TYPE||',' , ',2,') = 0 and instr(','||F1.SERVICE_TYPE||',' , ',6,') = 0 and instr(','||F1.SERVICE_TYPE||',' , ',7,') = 0 then nvl(F4.ACTIVE_VERIFYRATE,'1') else nvl(F4.ACTIVE_VERIFYRATE,F7.COMPARE_FREQ) end ACTIVE_VERIFYRATE, nvl(F4.PUBLISH_RATE,'3') PUBLISH_RATE, nvl(F4.PUBLISH_STATE,'1') PUBLISH_STATE, F3.VC_SJLY, F5.HAND_REASON, F1.SERVICE_TYPE, f6.INST_ID, F3.VC_FJJJDM, F3.L_JJJB, cast(F3.EN_LJDWJZ as decimal(20,4)) EN_LJDWJZ, F3.D_SCSJ, f1.FUND_TYPE, f1.TRANSACTION_SERVICE_TYPE, f7.FUND_ORIGIN_INFO, f7.SETTLEMENT_MODE, f1.NON_STANDARD_PDT, f1.SPECIAL_RISK_TYPE from amos_pdt_fundinfo f1 inner join amos_base_fundauthdetal f2 on f1.fund_id = f2.fund_id and f2.user_id = ? inner join ( select t.vc_jjdm fund_code, h.vc_name fund_name, h.vc_glr, h.vc_tgr, a.d_scsj, a.d_ywrq d_gzrq, nvl(a.l_sfqr, -1) l_sfqr, a.d_qrsj, decode(b.l_dzjg,null,0,1,9,9,1,0) L_WBHDJG, 'TG' VC_SJLY, decode(t.l_jjjb, 0, 1, 1, 0) l_sfmjj, t.l_ztbh, t.d_rq, t.en_dwjz, t.en_zcjz, t.en_zcfe, t.vc_fjjjdm, t.l_jjjb, t.en_ljdwjz from tgcbs.tjjmrhjsj t inner join tgcbs.ttmpgzb_index a on t.l_ztbh = a.l_ztbh and t.d_rq = a.d_ywrq left join ( select l_ztbh, l_dzjg, d_begin from ( select t.l_ztbh, t.l_dzjg, t.d_begin, row_number() over(partition by t.l_ztbh,t.d_begin order by desc ) rn from tgcbs.tycdz_tgr_zb t where t.l_sfbz = 0 and t.vc_wjlx='1011' and t.d_begin between to_date(?,'yyyy-mm-dd') and to_date(?,'yyyy-mm-dd') ) where rn = 1 ) b on t.l_ztbh = b.l_ztbh and b.d_begin = t.d_rq, ( select g.vc_mc vc_glrmc, f.vc_glr, f.vc_tgr, f.vc_name, f.l_fundid from tgcbs.tfundinfo f left join tgcbs.tglrxx g on f.vc_glr = g.vc_bh ) h where 1 = 1 and a.d_ywrq between to_date(?,'yyyy-mm-dd') and to_date(?,'yyyy-mm-dd') and ((t.l_jjjb = 0 and ? = 1) or (t.l_jjjb > 0 and ? = 2) or ? = 0) and h.l_fundid = t.l_ztbh ) f3 on f3.fund_code = f1.fund_code LEFT JOIN amos_base_instinfo f6 ON f1.manager_id = f6.inst_id left join amos_qyrpt_valuationset f4 on f3.fund_code = f4.fund_code and f4.fund_id = f1.fund_id and f4.data_source = 'TG' left join amos_qyrpt_valuationvalue f5 on f3.fund_code = f5.vc_fundcode and f3.d_rq = f5.d_rq and f5.vc_sjly = 'TG' left join AMOS_PDT_FUNDINFOEX F7 on f1.fund_id = f7.fund_id left join amos_pdt_valuation_fund F9 on f9. l_fundid = f3.L_ZTBH left join SYS_MAIL_SENDLIST_M m on m.FUND_ID = f1.FUND_ID and m.business_date=f3.d_rq and m.FUND_CODE = f3.FUND_CODE and m.REPORT_TYPE = '101' WHERE 1=1 and F1.fund_code in ( select apfa.fund_code from amos_pdt_fundInfo apfa where (instr(','||apfa.SERVICE_TYPE||',' , ',1,') > 0) ) ) ALLDATA left join AMOS_PDT_FUNDCONTRELA apf on ALLDATA.FUND_ID=apf.FUND_ID where 1 = 1 and ((ALLDATA.D_RQ = to_date(?,'yyyy-mm-dd') and ALLDATA.L_SFQR = '1') or (ALLDATA.D_RQ != to_date(?,'yyyy-mm-dd'))) order by ALLDATA.d_rq desc, ALLDATA.fund_id desc) tmp_count ### Cause: java.sql.SQLSyntaxErrorException: ORA-00936: missing expression ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: ORA-00936: missing expression 什么问题
最新发布
12-20
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值