Chandrashekar
7/17/2016 - 5:34 PM

Audit Type Wise Section to question Query

Audit Type Wise Section to question Query

SELECT Section.Id, Section.NAME AS SectionName, SubSection.NAME AS SubSectionName, GroupNode.NAME AS GroupName,atx.QuestionId,qm.QuestionText FROM 
dbo.AuditTypeXQuestion atx
INNER JOIN dbo.QuestionMaster qm ON atx.QuestionId = qm.Id
INNER JOIN dbo.HierarchyMaster GroupNode ON GroupNode.Id = qm.HierarchyId
INNER JOIN dbo.HierarchyMaster SubSection ON SubSection.Id = GroupNode.ParentId
INNER JOIN dbo.HierarchyMaster Section ON Section.Id = SubSection.ParentId
INNER JOIN dbo.AuditTypeMaster atm ON atx.AuditTypeId = atm.Id
WHERE atm.[Key] = 'CDQ'
ORDER BY SectionName,SubSectionName