我的查询有问题......
这个有效:
select name, bday, address, dbms_random.value(1, 100) as joker
from employee
order by joker asc
但是当我尝试使用'where'和group / having子句获得我想要的东西时,我得到一个ora-00904(无效的标识符)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
这可能是我的问题,如何使用joker列进行查询?
答案 0 :(得分:3)
尝试:
Select * from
(select name, bday, address, dbms_random.value(1, 100) as joker
from employee)
where joker>5
order by joker asc
答案 1 :(得分:0)
GOOD。之所以有用,是因为您可以按表达式对列表进行排序/分组/过滤,但是不能对在同一查询中给定表达式的名称进行分类/分组/过滤。通过将查询与对DBMS_RANDOM.VALUE的调用嵌套在一起,别名JOKER可用于外部查询中的ORDER BY子句。 –