我有以下查询,它返回2011 年 StackOverflow 上每天的androidROLLUP
问题数。我想得到 2011 年提出的所有问题的总和。为此,我使用.
select
year(p.CreationDate) as [Year],
month(p.CreationDate) as [Month],
day(p.CreationDate) as [Day],
count(*) as [QuestionsAskedToday]
from Posts p
inner join PostTags pt on p.id = pt.postid
inner join Tags t on t.id = pt.tagid
where
t.tagname = 'android' and
p.CreationDate > '2011-01-01 00:00:00'
group by year(p.CreationDate), month(p.CreationDate),day(p.CreationDate)
with rollup
order by year(p.CreationDate), month(p.CreationDate) desc,day(p.CreationDate) desc
这是输出:
2011 年每天提出的所有问题的总和显示在 QuestionsAskedToday 列本身中。
有没有办法在带有别名的新列中显示汇总?