当我执行SQL时出错:
选择bd.name aaa,
总和(p.nassistnum)HH,总和(当p.vbdef4 ='〜'然后' 0'否则p.vbdef4结束时的情况)KK
来自ic_purchasein_b p,bd_marbasclass bd,bd_material_v m,ic_purchasein_h h
其中m.pk_source = p.cmaterialvid 和p.cgeneralhid = h.cgeneralhid
和bd.code = substr(m.code,0,4)
和m.creator =' 1001A210000000000IIQ'
和h.vdef8 =' 1001A2100000000FUD01'
并且h.ctrantypeid =' 1001A210000000002UXJ'
和h.pk_org in(参数(' param3'))
和substr(h.dbilldate,1,10)> =参数(' param1')
和substr(h.dbilldate,1,10)< =参数(' param2')
由bd.name组成的组aaa
[错误] ORA-00904:" PARAMETER":无效标识符
我的SQL是:
select DISTINCT aaa,sum(HH) sum1,sum(KK) sum2 from
( select bd.name aaa,
sum(p.nassistnum) HH,sum(case when p.vbdef4='~' then '0' else p.vbdef4 end) KK
from ic_purchasein_b p,bd_marbasclass bd,bd_material_v m ,ic_purchasein_h h
where m.pk_source=p.cmaterialvid
and p.cgeneralhid= h.cgeneralhid
and bd.code=substr(m.code,0,4)
and m.creator='1001A210000000000IIQ'
and h.vdef8='~'
and (h.ctrantypeid='1001A210000000002UXJ' or h.ctrantypeid='1001A210000000002UW7' or h.ctrantypeid='1001A210000000002UY9')
and h.pk_org in (parameter('param3'))
and substr(h.dbilldate,1,10) >= parameter('param1')
and substr(h.dbilldate,1,10) <= parameter('param2')
group by bd.name
UNION
select bd.name aaa,
sum(p.nassistnum) HH,sum(case when p.vbdef4='~' then '0' else p.vbdef4 end) KK
from ic_purchasein_b p,bd_marbasclass bd,bd_material_v m ,ic_purchasein_h h
where m.pk_source=p.cmaterialvid
and p.cgeneralhid= h.cgeneralhid
and bd.code=substr(m.code,0,4)
and m.creator='1001A210000000000IIQ'
and h.vdef8='1001A2100000000FUD01'
and h.ctrantypeid='1001A210000000002UXJ'
and h.pk_org in (parameter('param3'))
and substr(h.dbilldate,1,10) >= parameter('param1')
and substr(h.dbilldate,1,10) <= parameter('param2')
group by bd.name) group by aaa
但我不知道错误在哪里,为什么我的PARAMETER是无效的标识符?
答案 0 :(得分:0)
ORA-00904字符串:无效标识符原因:输入的列名是 要么丢失要么无效。
操作:输入有效的列名称。有效的列名必须以。开头 一个字母,小于或等于30个字符,仅由 字母数字字符和特殊字符$,_和#。如果它 包含其他字符,然后必须用double括起来 引号。它可能不是一个保留字。
您可能只需要在查询中重新检查列名和函数。
肯定会考虑@Alex Poole的评论。