在mssql中有数据库A和B。分别有表结构如下

查询条件:
A.a.outdate>='20140201';A.a.price>0
对sum(A.a.goods_nb)进行排序,A.a.goods_no进行分组
然后连接B.b查询出goods_pic
求个sql语句实现以上查询
------解决方案--------------------
再修改一下:
declare @page_size int;
declare @page_num int;
--比如:每页10条记录
set @page_size = 10;
--比如:先取第1页
set @page_num = 1;
select *
from
(
select a.s_nb,
b.*,
(row_number() over(order by a.s_nb) - 1) / @page_size as rownum
from
(
select SUM(nb) as s_nb,colthno
from cmd_xjjx_sale
where outdate<='20140223' and outdate>='20140216' and endprice>0
group by colthno
)a
inner join BI数据仓库.dbo.BI_colthno_kind b
on a.colthno=b.colthno
)t
where rownum = @page_num - 1