I tried to select a random data from table employees with query rand() but it can happen
SELECT email FROM employees
ORDER BY RAND()
LIMIT 1;
and the output is:
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
Can somebody tell me why??
The Oracle equivalent of rand() is dbms_random.value.
The Oracle equivalent of limit is either a subquery with rownum or (in Oracle 12) fetch first xx row only. So, one of these should work:
select email
from employees
order by dbms_random.value
fetch first 1 row only;
or:
select email
from (select email
from employees
order by dbms_random.value
) e
where rownum = 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With