我正在处理T-SQL脚本,其中有列Sum值,现在我需要添加所有行值并用于计算百分比。我的问题是,考虑到这一行也做了count()
,我如何对所有行的值求和SELECT
q.Id AS QuestionId,
ansOpt.QuestionOptionId AS QuestionOptionId,
qOpt.Value,
COUNT(ansOpt.QuestionOptionId) AS QuestionOptionCount,
(((CONVERT(DECIMAL, COUNT(ansOpt.QuestionOptionId)))) / 8) * 100 AS AnswerCoutPercentage
-- COUNT(QuestionOptionCount) // need help here
FROM
[dbo].[Responses] AS res
GROUP BY
q.Id, ansOpt.QuestionOptionId, qOpt.Value
答案 0 :(得分:0)
我找到了答案,因为我需要使用存储过程,所以我按照以下方式进行了操作
DataSet