首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > IBM DB2 >

哪位知道db2 分页 取总记录数 如何写的

2014-01-14 
哪位知道db2 分页 取总记录数 怎么写的。select id,a001,a002,a008,c0101,c0102,c0103,bjje,c010 , count f

哪位知道db2 分页 取总记录数 怎么写的。
select id,a001,a002,a008,c0101,c0102,c0103,bjje,c010 , count from (select max(a.id) id,a.a001 a001,count(a.a001)  count,max(b.a002) a002,max(b.a008) a008,max(a.c0101) c0101,  max(a.c0102) c0102,max(a.c0103) c0103,max(a.c010) c0104,
max(a.c0101+a.c0102) c010,max(case when c006<>'01' then c010 else 0 end) bjje,rownumber() over(order by a.a001 asc ) as rowid from gz_gr_hbj a  left join gz_gr_zz b on
 b.a000=a.a000 where a.c013= '11309180101_00008737' and a.c009='201308' group by a.a001 ) where rowid >= 1 AND rowid <11 

这是我写的语句  但count()怎么查询出来的是1啊? 数据库
[解决办法]
查分页也不用这么复杂啊,如果你真的想一条语句实现的话可以用分析函数:


select * from (
  select t.*,count() over() as num,rownumber() over() as rowid
  from table t
) a where a.rowid between 1 and 10
 
 

热点排行