【发布时间】:2011-03-04 04:25:35
【问题描述】:
到目前为止,我在存储过程中使用了两个声明的变量:
SET @QuestionPoints = (SELECT SUM(points)
FROM tb_responses
WHERE userid = @UserId
AND id = @ID)
SET @EventPoints =(SELECT SUM(dbo.tb_events.points)
FROM dbo.tb_attendance
INNER JOIN dbo.tb_events
ON dbo.tb_attendance.eventid = dbo.tb_events.dbid
WHERE dbo.tb_attendance.userid = @UserID
AND dbo.tb_attendance.didattend = 'Y'
AND dbo.tb_events.id = @ID)
如何将@QuestionPoints 和@EventPoints 相加以获得总分?我可以使用“+”将它们添加并分配给第三个声明的变量还是有一个整体声明?
谢谢,
詹姆斯
【问题讨论】:
-
一个更合适的标题应该是“两个声明的变量”而不是值。感谢所有这么快回复的人。
标签: sql sql-server-2008 stored-procedures sum