我正在与 SEDE 合作创建投票与帖子比率的图表。消除了所有实际错误后,我面临一个新问题:由于某种原因,比率始终为1。这是当前的 SQL:
SELECT CAST(p.CreationDate AS DATE) AS [CreationDate],
COUNT(CAST(v.CreationDate AS DATE)) / COUNT(CAST(p.CreationDate AS DATE))
AS [Ratio]
FROM Posts p
INNER JOIN Votes v ON v.PostId = p.Id
WHERE v.VoteTypeId = ##VoteType:int?2## AND
p.PostTypeId = 1 OR p.PostTypeId = 2
GROUP BY CAST(p.CreationDate AS DATE)
ORDER BY Ratio
查询本身可以在这里找到。
聊天中建议这可能是因为加入表格会导致所有可能的组合,因此投票和帖子的数量总是相同的(因此n/n = 1
)。这是正确的,如果是这样,我应该怎么做?