DECLARE @TotalQuestions int;
DECLARE @CorrectQuestions int;
DECLARE @IncorrectQuestions int;
SELECT (
SET CorrectQuestion = SELECT COUNT( WiningComment)
FROM Threads
WHERE WiningComment IN (SELECT CommentsID
FROM Comments
WHERE UsersID=@UserID)
) as 'WinningAnswers',
(
SET TotalQuestions = SELECT COUNT(CommentsID)
FROM Comments
WHERE UsersID=@UserID
) as 'TotalAnswers'
(
SELECT (TotalQuestions-CorrectQuestions ) //I am not sure about this part!!
) as 'IncorrectQuestions'
I am not sure about the last part, I want to subtract the results of one subquery from the results of another subquery
Try this: