--统计今日金额合并为一条。一天一条数据 create proc sp_tablename @uid int, @bid int as begin select sum([money]) as [money], convert(varchar(100), createtime, 23) as createtime from dbo.tablename where (uid = @uid) and (mid = @bid) group by convert(varchar(100), createtime, 23) end --分页: create proc sp_tablenamebypage @uid int, @bid int, @pageindex int=1, -- 第几页 @pagesize int=10 -- 每页包含的记录数 @pagecount int output, --总页数 @datacount int output --总的记录条数 as begin select top (select @pagesize) * -- 这里注意一下,不能直接把变量放在这里,要用select from (select row_number() over(order by convert(varchar(100), createtime, 23)) as rownumber, sum([money]) as [money], convert(varchar(100), createtime, 23) as createtime from dbo.tablename where (uid = @uid) and (bonusid = @bid) group by convert(varchar(100), createtime, 23)) temp_row where rownumber>(@pageindex-1)* @pagesize; set @datacount = (select count(*) from dbo.tablename) set @pagecount = (ceiling(@datacount*1.0/@pagesize)) end
存储过程!~