I have the following SQL.
SELECT t0.QustionId, t1.QuestionText, t2.AnswerText FROM
ActiveQuestion AS t0
INNER JOIN Question AS t1
ON t1.QuestionId = ActiveQuestion.QuestionId
LEFT OUTER JOIN Answer AS t2
ON t2.SectionId = t0.SectionId
AND t1.ParentId IN
(SELECT QuestionId
FROM Question WHERE SharedQuestionId = t2.SharedQeustionId)
Questions can be shared (with the same SharedQuestionId), questions can have parent question.
I want get rid of the subquery. What is the proper way to do it?
JOINthe tableQuestionone more time with different alias: