SELECT
AssessmentItem.ItemName
,AssessmentItem.OthersSelfClass
,AssessmentItem.FourStageClass
,AssessmentComment.CommentText
,AssessmentComment.ItemID
,ROUND(COALESCE(vProjectRespondentScoreCompany.score ,0), 1) AS score
,(SELECT COUNT(vProjectRespondentScoreCompanyRank.score)
FROM vProjectRespondentScoreCompany AS vProjectRespondentScoreCompanyRank
WHERE vProjectRespondentScoreCompanyRank.AssessmentID = 9
AND vProjectRespondentScoreCompanyRank.score > vProjectRespondentScoreCompany.score) + 1 AS rank
FROM AssessmentItem
JOIN AssessmentComment ON (AssessmentComment.ItemID = AssessmentItem.ItemID)
LEFT OUTER JOIN vProjectRespondentScoreCompany ON (vProjectRespondentScoreCompany.ItemID = AssessmentItem.ItemID AND vProjectRespondentScoreCompany.AssessmentID = 9)
LEFT JOIN SortOrder ON (AssessmentItem.OthersSelfClass = SortOrder.TargetString)
WHERE 0 = 0
AND SortOrder.TargetTable = 'AssessmentItem'
AND SortOrder.TargetItem = 'OthersSelfClass'
ORDER BY vProjectRespondentScoreCompany.score DESC,CAST(SUBSTRING(AssessmentComment.ItemID ,2) AS signed) ASC
AssessmentItem.ItemName
,AssessmentItem.OthersSelfClass
,AssessmentItem.FourStageClass
,AssessmentComment.CommentText
,AssessmentComment.ItemID
,ROUND(COALESCE(vProjectRespondentScoreCompany.score ,0), 1) AS score
,(SELECT COUNT(vProjectRespondentScoreCompanyRank.score)
FROM vProjectRespondentScoreCompany AS vProjectRespondentScoreCompanyRank
WHERE vProjectRespondentScoreCompanyRank.AssessmentID = 9
AND vProjectRespondentScoreCompanyRank.score > vProjectRespondentScoreCompany.score) + 1 AS rank
FROM AssessmentItem
JOIN AssessmentComment ON (AssessmentComment.ItemID = AssessmentItem.ItemID)
LEFT OUTER JOIN vProjectRespondentScoreCompany ON (vProjectRespondentScoreCompany.ItemID = AssessmentItem.ItemID AND vProjectRespondentScoreCompany.AssessmentID = 9)
LEFT JOIN SortOrder ON (AssessmentItem.OthersSelfClass = SortOrder.TargetString)
WHERE 0 = 0
AND SortOrder.TargetTable = 'AssessmentItem'
AND SortOrder.TargetItem = 'OthersSelfClass'
ORDER BY vProjectRespondentScoreCompany.score DESC,CAST(SUBSTRING(AssessmentComment.ItemID ,2) AS signed) ASC
Comments
Post a Comment