怎么统计分页里的数据
select top (10) m.id,m.Memid,m.Name,m.LoginName,m.adName,
(select count(*) from dbo.MemConcern where memid=m.MemId and CreateTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29') as GZCount,
(select count(*) from dbo.MemConcern where ConcernId=m.MemId and CreateTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29')as BGZCount,
(select count(*) from dbo.QTopicConcern where MemId=m.MemId and CreateTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29') as GZHTCount,
(select count(*) from dbo.QuestionConcern where MemId=m.MemId and CreateTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29')as GZQuestionCount,
(select count(*) from dbo.QAnswer where Answerer=m.MemId and AnswerTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29')as AnswerCount,
(select count(*) from dbo.QusetionMem where memid=m.MemId and CreateTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29') as BTWCount,
(select count(*) from dbo.Question where memid=m.MemId and CreateTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29') as TWCount,
(select count(*) from dbo.QAnswerVote where voters=m.MemId and VoteTime
between '2000-1-1 0:00:00' and '2012-8-14 15:10:29') as TPCount
from dbo.MemberSpecial as m where 1=1 and m.id not in
(select top(0) id from dbo.MemberSpecial order by Memid desc)
order by Memid desc 我要获得sum(GZCount) ,因为那些统计的字段都是其他表的,如何获得,
------解决方案--------------------没看懂问题,等高人。
GZCount已经是sum了啊。
------解决方案--------------------
先分页在统计。
你分页得到的十条或者20条记录放到临时表里面,然后再去统计,这样你不就好写多了