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 nam开发者_运维知识库e, bday, address
having joker > 5
order by joker asc
What could be my problem here and how can i query using the joker column?
try:
Select * from
(select name, bday, address, dbms_random.value(1, 100) as joker
from employee)
where joker>5
order by joker asc
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. –
精彩评论