Oracle新手错误:ORA-00904使用“case-when”时标识符无效
我在查询中遇到一个错误。此查询正常,返回用于分页的selects和rownums数据:Oracle新手错误:ORA-00904使用“case-when”时标识符无效,oracle,identifier,ora-00904,case-when,Oracle,Identifier,Ora 00904,Case When,我在查询中遇到一个错误。此查询正常,返回用于分页的selects和rownums数据: select * from (select a.*, rownum rnum from (select id_edition, id_document, name, extension, creation_date, url, (select inscription_date from edition_student_d0 where id_edition = 12345 and id_third =
select *
from (select a.*, rownum rnum
from (select id_edition, id_document, name, extension, creation_date, url,
(select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) inscription_date
from upd_edition_doc_d0
where id_edition = 1071591
order by creation_date desc) a
where rownum <= 10 )
where rnum >= 1
我想这是因为我要求在同一查询级别上使用铭文_date,但我不知道如何处理这个问题
还有,我怎样才能做我想做的?我的意思是,只有在一定条件下才能获取url
有人能帮忙吗
提前感谢。您不能在同一查询级别中引用别名 您可以替换子查询
select *
from (select a.*, rownum rnum
from (select id_edition, id_document, name, extension, creation_date,
(select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) inscription_date,
case when trunc((select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) + 90) <= trunc(sysdate) then null
else url
end as url
from upd_edition_doc_d0
where id_edition = 1071591
order by creation_date desc) a
where rownum <= 10 )
where rnum >= 1
或者把箱子上移一层
select *
from (select a.*,
case when trunc(inscription_date + 90) <= trunc(sysdate) then null
else url
end as url,
rownum rnum
from (select id_edition, id_document, name, extension, creation_date,
(select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) inscription_date
from upd_edition_doc_d0
where id_edition = 1071591
order by creation_date desc) a
where rownum <= 10 )
where rnum >= 1
在我自己尝试之后,我找到了你的第一个解决方案,没有第一个选择的题词。。。。但第二种解决方案是最优雅的,我稍后会尝试!非常感谢你:
select *
from (select a.*, rownum rnum
from (select id_edition, id_document, name, extension, creation_date,
(select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) inscription_date,
case when trunc((select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) + 90) <= trunc(sysdate) then null
else url
end as url
from upd_edition_doc_d0
where id_edition = 1071591
order by creation_date desc) a
where rownum <= 10 )
where rnum >= 1
select *
from (select a.*,
case when trunc(inscription_date + 90) <= trunc(sysdate) then null
else url
end as url,
rownum rnum
from (select id_edition, id_document, name, extension, creation_date,
(select inscription_date from edition_student_d0 where id_edition = 12345 and id_third = 12345) inscription_date
from upd_edition_doc_d0
where id_edition = 1071591
order by creation_date desc) a
where rownum <= 10 )
where rnum >= 1