select t.* from (
select rownum as rn, a.emp_id,a.service_date,a.customer_id,a.service_type from
(select s.PROCESSER_ID as emp_id,to_char(s.done_date,'yy-mm-dd') as service_date,s.customer_id ,s.customer_tax_id,decode(s.service_type_id,1,'维护',4,'回访') as service_type
from EMP_SERVICE2014 s
where s.service_type_id in(1,4)
and s.processer_id=216491
UNION all
select p.fee as emp_id,to_char(p.visit_end_date,'yy-mm-dd') as service_date,p.customer_id,p.customer_tax_id,'回访' as service_type
from EMP_PV2014 p
where p.fee=216491
and not exists (select 1 from emp_service2014 s where p.customer_id=s.customer_id and to_char(p.visit_end_date,'yyyy-mm-dd')=to_char(s.done_date,'yyyy-mm-dd')and s.service_type_id in(1,4))
) a
where rn<50
)t
where t.rn>10
请问这样写分页为什么不行啊????我的目的是 从查询的结果集a 中实现分页!!
求大神们解答!
------解决方案--------------------
select t.*
from (select rownum as rn,
a.emp_id,
a.service_date,
a.customer_id,
a.service_type
from (select s.PROCESSER_ID as emp_id,
to_char(s.done_date, 'yy-mm-dd') as service_date,
s.customer_id,
s.customer_tax_id,
decode(s.service_type_id, 1, '维护', 4, '回访') as service_type
from EMP_SERVICE2014 s
where s.service_type_id in (1, 4)
and s.processer_id = 216491
UNION all
select p.fee as emp_id,
to_char(p.visit_end_date, 'yy-mm-dd') as service_date,
p.customer_id,
p.customer_tax_id,
'回访' as service_type
from EMP_PV2014 p
where p.fee = 216491
and not exists
(select 1
from emp_service2014 s
where p.customer_id = s.customer_id
and to_char(p.visit_end_date, 'yyyy-mm-dd') =
to_char(s.done_date, 'yyyy-mm-dd')