我不知道为什么查询中的第三个联合会没有给我返回结果。
当我使用第一个两个联合运行它时,它工作正常,当我添加第三个联合时,它给了我这个错误-
”由以下原因引起:Org.eclipse.birt.data.engine.odaconsumer.OdaDataException:无法获取结果集meta.org.eclipse.birt.report.data.oda.jdbc.JDBCException:SQL语句未返回ResultSet对象。SQL错误1:java.sql.SQLException:java.sql.SQLException:ORA-00923:在预期的“
中找不到FROM关键字”我正在尝试在第三联合中增加一个具有该项目完成状态的列-特定项目未链接到限定词-
select innerpart.*,
DECODE(INNERPART.cpnt_id,'26001', INNERPART.GRADE) as "MWOR Grade"
FROM
(Select
s.stud_id as UserID,
s.fname,
s.mi,
s.lname,
trim(s.lName||', '||s.fName||' '||s.mi) "Full Name",
qq.cpnt_id,
QQ.CMPL_STAT_ID,
qq.compl_dte,
qq.qual_id,
Q.QUAL_TITLE "Qual Title" ,
Q.QUAL_DESC "Qual Description",
pkg_student.get_delm_stud_qual_stat_rmday (qq.stud_id, qq.qual_id, qq.qual_id_root) AS status_remday,
null as grade
null as compl_date
from pa_student s,
pa_stud_qual_cpnt qq,
pa_qual q
where s.stud_id = '01775154'
and S.STUD_ID = QQ.STUD_ID
and q.qual_id = QQ.QUAL_ID
and (q.qual_id = 'ENG_CURR_SAFETY CERT'
or q.qual_id ='ENG_CURR_BOOK OF RULES'
or q.qual_id ='ENG_CURR_FALL PROTECTION BASEL'
or q.qual_id ='ENG_CURR_BRIDGE WORRKER RESCUE'
or q.qual_id ='ENG_BNSF_EI25'
or q.qual_id ='ENG_CURR_PTC'
or q.qual_id ='ENG_CURR_PTC TELECOM 220 RADI'
or q.qual_id ='ENG_CURR_BROKEN RAIL'
or q.qual_id ='ENG_SMITH_SYTEM_DRIVER_DIRECT'
or q.qual_id ='ENG_CURR_TRACK STABILITY'
or q.qual_id ='ENG_CURR_OPT_TRACK STABILITY'
or q.qual_id ='ENG_CURR_FRA TIER II'
or q.qual_id ='ENG_CURR_TIER III'
or q.qual_id ='ENG_CURR_TIER III CONTINUE ED')
and qq.compl_dte >='01-JAN-2018'
and qq.compl_dte <='31-DEC-2018'
UNION
Select
s.stud_id as UserID,
s.fname,
s.mi,
s.lname,
trim(s.lName||', '||s.fName||' '||s.mi) "Full Name",
qq.cpnt_id,
QQ.CMPL_STAT_ID,
qq.compl_dte,
qq.qual_id,
Q.QUAL_TITLE "Qual Title" ,
Q.QUAL_DESC "Qual Description",
pkg_student.get_delm_stud_qual_stat_rmday (qq.stud_id, qq.qual_id, qq.qual_id_root) AS status_remday,
e.grade AS grade
null as compl_date
from pa_student s,
pa_stud_qual_cpnt qq,
pa_qual q,
PA_CPNT_EVTHST e
where s.stud_id = '01775154'
and S.STUD_ID = QQ.STUD_ID
and q.qual_id = QQ.QUAL_ID
and (q.qual_id = 'ENG_CURR_SAFETY CERT'
or q.qual_id ='ENG_CURR_BOOK OF RULES'
or q.qual_id ='ENG_CURR_FALL PROTECTION BASEL'
or q.qual_id ='ENG_CURR_BRIDGE WORRKER RESCUE'
or q.qual_id ='ENG_BNSF_EI25'
or q.qual_id ='ENG_CURR_PTC'
or q.qual_id ='ENG_CURR_PTC TELECOM 220 RADI'
or q.qual_id ='ENG_CURR_BROKEN RAIL'
or q.qual_id ='ENG_SMITH_SYTEM_DRIVER_DIRECT'
or q.qual_id ='ENG_CURR_TRACK STABILITY'
or q.qual_id ='ENG_CURR_OPT_TRACK STABILITY'
or q.qual_id ='ENG_CURR_FRA TIER II'
or q.qual_id ='ENG_CURR_TIER III'
or q.qual_id ='ENG_CURR_TIER III CONTINUE ED')
AND e.stud_id = s.stud_id
AND qq.cpnt_typ_id = e.cpnt_typ_id
AND qq.cpnt_id = e.cpnt_id
AND qq.rev_dte = e.rev_dte
and qq.compl_dte >='01-JAN-2018'
and qq.compl_dte <='31-DEC-2018'
UNION
Select
s.stud_id as UserID,
s.fname,
s.mi,
s.lname,
trim(s.lName||', '||s.fName||' '||s.mi) "Full Name",
null as qq.cpnt_id,
null as QQ.CMPL_STAT_ID,
null as qq.compl_dte,
null as qq.qual_id,
null as "Qual Title" ,
null as "Qual Description",
null AS status_remday,
null AS grade
cpnt.compl_date as compl_date
from pa_student s,
pa_stud_qual_cpnt qq,
pa_qual q,
PA_CPNT_EVTHST e,
PA_STUD_CPNT cpnt
where s.stud_id = '01775154'
and (cpnt.cpnt_id = '56001' or cpnt.cpnt_id = '59001')
and S.STUD_ID = cpnt.STUD_ID
AND e.stud_id = s.stud_id
AND cpnt.cpnt_typ_id = e.cpnt_typ_id
AND cpnt.cpnt_id = e.cpnt_id
AND cpnt.rev_dte = e.rev_dte
and cpnt.compl_dte >='01-JAN-2018'
and cpnt.compl_dte <='31-DEC-2018'
) innerpart
Order by UserID
答案 0 :(得分:1)
您有两个语法错误(都是同一种语法:SELECT
列表中缺少逗号)。当你写类似
select column1 as alias1
column2
from table1
-注意语法错误,第一列及其SELECT
中的别名后面没有逗号-Oracle希望在FROM
之后看到关键字column1
,而不是列名或还有什么。
因此,找到丢失的逗号,将其重新添加,然后看看会发生什么。顺便说一句,它们是三元组UNION
的前两个成员,所以当您说“添加第三个成员”是导致错误的原因时,我不相信您。相反,我想,当您添加第三个成员时,您还向前两个成员的SELECT
列表中添加了更多内容。
缺少逗号:第一个null as grade
的{{1}}之后和第二个SELECT
的{{1}}之后。