日期:2014-05-16 浏览次数:20604 次
declare @page_size int;
declare @page_num int;
set @page_size='10';
set @page_num='1'
select * from
(
select
colthno,Quantity_sold,bcolthno,sum_order,rkcolthno,sum_deli,
(row_number() over (order by Quantity_sold desc)-1)/@page_size as rownum
from
(
select * from
(
select * from
(
select b.colthno,sum(s.nb) Quantity_sold from CMD..cmd_xjjx_sale s ,BI_Product_Information b
where s.colthno=b.colthno
and b.classname8='13FW'
and s.endprice>0
group by b.colthno
) a
left join
(
select b1.colthno bcolthno,sum(order_quantity) sum_order
from BI_order bo,BI_Product_Information b1
where b1.classname8='13FW'
and bo.colthno=b1.colthno
group by b1.colthno
)b
on a.colthno=b.bcolthno
)x left join
(select b1.colthno rkcolthno,SUM(rk_nb) sum_deli
from BI_Product_Information b1,BI_RK rk1
where b1.classname8='13FW'
and b1.colthno=rk1.colthno
group by b1.colthno
)y
on x.colthno=y.rkcolthno
) t
)t2
where rownum = @page_num - 1