select
nvl(sum(nvl(t.xxxxxxx,0) * nvl(t.xxxxxxx,1) * nvl(tpdc.xxxxxxx,0)),0)
into sp_sum_fee
from intf_policy t
left join (select * from xxxxxxx
where (EXISTS(select * from xxxxxxxwhere xxxxxxx='0104') and xxxxxxx='0104')
or
( not EXISTS(select * from xxxxxxxwhere xxxxxxx='0104') and xxxxxxx= '0104')) tpdc
on t.xxxxxxx= tpdc.xxxxxxx
left outer join xxxxxxxt1 on t.xxxxxxx= t1.person_code
left outer join xxxxxxxt2 on t1.sid = t2.pid and t.xxxxxxxbetween t2.start_date and t2.end_date
left outer join t_team t3 on t2.tid = t3.sid
where t1.person_code = 12121212
and t.fee_type = '2'
and to_date(to_char(t.biz_date,'yyyy-MM-dd'),'yyyy-MM-dd') between 2022-03-01 and 2022-03-31;
改为:
select
nvl(sum(nvl(t.xxxxxxx,0) * nvl(t.xxxxxxx,1) * nvl(tpdc.xxxxxxx,0)),0)
--into sp_sum_fee
from intf_policy t
left join (select * from xxxxxxx
where (EXISTS(select * from xxxxxxxwhere xxxxxxx='0104') and xxxxxxx='0104')
or
( not EXISTS(select * from xxxxxxxwhere xxxxxxx='0104') and xxxxxxx= '0104')) tpdc
on t.xxxxxxx= tpdc.xxxxxxx
left outer join xxxxxxxt1 on t.xxxxxxx= t1.person_code
left outer join xxxxxxxt2 on t1.sid = t2.pid and t.xxxxxxxbetween t2.start_date and t2.end_date
left outer join t_team t3 on t2.tid = t3.sid
where t1.person_code = '12121212'
and t.fee_type = '2'
and to_date(to_char(t.biz_date,'yyyy-MM-dd'),'yyyy-MM-dd') between to_date('2022-03-01','yyyy-MM-dd') and to_date('2022-03-31','yyyy-MM-dd');
ORA-00905: 缺失关键字
这里姜老师把--into sp_sum_fee注释掉后就正常了
ORA-01722: 无效数字无效数字
然后注意person_code = 12121212给字符串加引号
ORA-00932: 数据类型不一致: 应为 DATE, 但却获得 NUMBER
然后 2022-03-01要将字符串转为时间格式:to_date('2022-03-01','yyyy-MM-dd')