ora-00904 invalid identifier

烈酒焚心 提交于 2019-12-12 03:53:28

问题


I am having problem with my query...

This one works:

  select name, bday, address, dbms_random.value(1, 100) as joker
    from employee 
order by joker asc

But when I try to get what I want using either the 'where' and group/having clause, I am getting a ora-00904 (invalid identifier) ERROR..

e.g.

  select name, bday, address, dbms_random.value(1, 100) as joker 
    from employee 
   where joker>5 
order by joker asc

  select name, bday, address, dbms_random.value(1, 100) as joker
    from employee 
group by name, bday, address 
  having joker > 5 
order by joker asc 

What could be my problem here and how can i query using the joker column?


回答1:


try:

Select * from
(select name, bday, address, dbms_random.value(1, 100) as joker 
from employee)
where joker>5 
order by joker asc



回答2:


GOOD.This works because you can sort/group/filter by an expression, but you can't sort/group/filter by the name you give the expression in the same query. By nesting the query with the call to DBMS_RANDOM.VALUE, the alias JOKER is available to the ORDER BY clause in the outer query. –



来源:https://stackoverflow.com/questions/3861416/ora-00904-invalid-identifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!