Skip to content

Instantly share code, notes, and snippets.

@byronferguson
Last active November 4, 2015 04:45
Show Gist options
  • Save byronferguson/45c6b80287ebe42466d4 to your computer and use it in GitHub Desktop.
Save byronferguson/45c6b80287ebe42466d4 to your computer and use it in GitHub Desktop.
SELECT (sr.studentResponseValue * cw.categoryWeightValue) AS weightedResponse
, cw.occupationalCategoryID AS cID
, iqo.interviewQuestionOptionID AS oID
FROM dbo.StudentResponseTable AS sr
INNER JOIN dbo.InterviewQuestionOptionTable AS iqo
ON (sr.interviewQuestionOptionID = iqo.interviewQuestionOptionID)
AND (sr.studentID = @studentID)
AND (iqo.interviewQuestionOptionActive = 1)
INNER JOIN dbo.CategoryWeightTable AS cw
ON (sr.interviewQuestionOptionID = cw.interviewQuestionOptionID)
SELECT studentID
, occupationalCategoryID
, SUM(weightedResponse) AS weightedResponseTotal
FROM dbo.weightedInterviewResponsesView
GROUP BY studentID, occupationalCategoryID
HAVING studentID = @studentID
ORDER BY weightedResponseTotal DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment