Logic is same for your question. You just need to get the question no count in @QuestionCount variable also For @CorrectAnswerCount variable From related table with respected count values as per single table query or as per Multiple table using joins. Always be proper with your table structure before posting any question so users can reply you accordingly.
kalpesh says:
SET
@QuestionCount = (
SELECT
COUNT
(*) questionid
FROM
#QuestionAnswer
WHERE
empid = @EmployeeId)
SET
@CorrectAnswerCount = (
SELECT
COUNT
(*)
FROM
#QuestionAnswer
WHERE
answerid = correctanswer
AND
empid = @EmployeeId)
Just replace as per your actual calculating table values as per yiur logic.
SET @QuestionCount = (SELECT COUNT(*) QuestionId FROM ResultTable WHERE Emp_Id = @EmployeeId)
SET @CorrectAnswerCount = (SELECT COUNT(*) FROM AnswerTable
INNER JOIN ResultTable ON AnswerTable.QuestionId = ResultTable.QuestionId
WHERE AnswerTable.AnswerId = ResultTable.AnswerId
AND ResultTable.Emp_Id = @EmployeeId)