I m trying to run this query but it returns zero rows. Any clues why?
Select distinct a.id
from table1 a, table b
where ( a.id= b.id or a.id = b.secondid ) and rownum < 200;
But if I run the above query without the ROWNUM clause it finds records:
Select distinct a.id
from table1 a, table b
where ( a.id= b.id or a.id = b.secondid );
I'm confused why the first query is not working.
You need to apply ROWNUM
after Oracle figures out which rows to return. The only reliable way is this:
SELECT * FROM (
Select distinct a.id
from table1 a, table b
where ( a.id= b.id or a.id = b.secondid )
) WHERE ROWNUM < 200;
Please use the thread below. Pretty good explanations. https://community.oracle.com/thread/210143 Here are two working solutions.
将“ and rownum <200”更改为“ WHERE rownum <200”
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.