oracle ora-00904 无效标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3861416/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ora-00904 invalid identifier
提问by Truth
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..
但是,当我尝试使用 'where' 和 group/sharing 子句获得我想要的东西时,我收到了一个 ora-00904(无效标识符)错误..
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?
我的问题可能是什么,我如何使用小丑列进行查询?
回答by Michael Pakhantsov
try:
尝试:
Select * from
(select name, bday, address, dbms_random.value(1, 100) as joker
from employee)
where joker>5
order by joker asc
回答by Jerry John
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. –
GOOD。这是可行的,因为您可以按表达式排序/分组/过滤,但不能按在同一查询中为表达式提供的名称进行排序/分组/过滤。通过将查询与调用 DBMS_RANDOM.VALUE 嵌套在一起,别名 JOKER 可用于外部查询中的 ORDER BY 子句。——