Stack Exchange 数据资源管理器允许对 Stack Exchange 数据库进行 SQL 查询。以下查询——</p>
select
month(CreationDate) month,
year(CreationDate) year,
sum(case when lower(left(Title,2))='wh' then 1 else 0 end)/count(*) wh,
(select sum(Score)/count(*)
from Posts u
where
month(CreationDate)=month(t.CreationDate) and
year(CreationDate)=year(t.CreationDate) and
lower(left(Title,2))='wh' and
PostTypeId=1 -- question
) wh_score,
sum(Score)/count(*) score,
(select sum(AnswerCount)/count(*)
from Posts u
where
month(CreationDate)=month(t.CreationDate) and
year(CreationDate)=year(t.CreationDate) and
lower(left(Title,2))='wh' and
PostTypeId=1 -- question
) wh_answers,
sum(AnswerCount)/count(*) answers
from Posts t
where PostTypeId=1 -- question
group by month(CreationDate), year(CreationDate)
;
—由Scorpi0提供 — 在结果中产生所有整数值:所有内容都被舍入或截断(我不知道是哪个)。(这在列中特别烦人,wh
因此每个值都是0
.)有没有办法强制小数或值?