SQL新建查询中→ORA-00905: 缺失关键字、 ORA-01722: 无效数字、ORA-00932: 数据类型不一致

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')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值