我正在从Java应用程序中读取表格,现在我想将这个任务分成两个不同的应用程序,每个应用程序都处理自己的行。
我试着用这个
Select * from emp where rownum between 0 and (Select count(*) from emp)/2;
我需要你的最佳方式来阅读下半部分的建议。
我试过
Select * from emp where rownum between ((Select count(*) from emp)/2)+1 and (Select count(*) from emp);
但它没有给我结果(给了我一套空的记录)
答案 0 :(得分:0)
rownum
被分配给行,因此您无法像以前那样使用它。相反,你可以做类似的事情:
select *
from (select rownum r, e.* from emp e)
where r between ((Select count(*) from emp)/2)+1 and (Select count(*) from emp);
答案 1 :(得分:0)
您还可以交错行
假设顺序id:
应用1:Select * from emp where mod(emp_id, 2) = 0;
应用2:Select * from emp where mod(emp_id, 2) = 1;
或
应用1:
WITH emp_ordered AS (Select * from emp order by emp_id)
Select * FROM (Select emp.*, rownum rn from emp_ordered) where mod(rn, 2) = 0;
App 2:
WITH emp_ordered AS (Select * from emp order by emp_id)
Select * FROM (Select emp.*, rownum rn from emp_ordered) where mod(rn, 2) = 1;