rollup问题

yinwun 2005-12-13 02:43:29
select top 10 L.[description],count(description) AS linkTotal,L.KeyPhrase from linktracker L
where L.dateEntered > '11/12/2005' and L.dateEntered < '12/13/2005' and KeyPhrase = 'Student Loan' and KeyPhrase is not null
group by L.[description],KeyPhrase with rollup

description LinkTotal KeyPharese
Email Sent 100 Student Loan
Email Sent 100 NULL
Got Link - 3 way link 200 Student Loan
Got Link - 3 way link 200 NULL
Got Link - free link 300 Student Loan
Got Link - free link 300 NULL

为什么加了rollup就出现一条重复额度记录。我想计算每一个total的总值
...全文
169 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
子陌红尘 2005-12-13
  • 打赏
  • 举报
回复
select
top 10
L.[description],
count(description) AS linkTotal,
L.KeyPhrase
from
linktracker L
where
L.dateEntered > '11/12/2005'
and
L.dateEntered < '12/13/2005'
and
KeyPhrase = 'Student Loan'
and
KeyPhrase is not null
group by
L.[description],KeyPhrase with rollup
having
grouping(L.[description])=1 or grouping(KeyPhrase)=0

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧