The screen shot was stripped please bear with me I will paste the original query and the original output now:
WITH cteTestGroups AS (SELECT MIN(A.iSrNo) AS iGroupSrNo , B.cTitle , MIN(C.iSrNo) AS iSubGroupSrNo , C.cSubGroup FROM sReqSlipTestGroup A JOIN mTestGroups B ON B.iID = A.iTestGroupID JOIN lTestGroupsTest C ON C.iPID = B.iID JOIN mTests D ON D.iID = C.iTestID WHERE A.iPID = 1 GROUP BY B.lNewPage , A.iSrNo , B.cTitle , C.cSubGroup ORDER BY 1, 2, 3, 4) SELECT cteTG.* FROM cteTestGroups cteTG 1 Haemogram Report 1 Routine Haemogram 1 Haemogram Report 5 Diff. Count (Mature Cells) 1 Haemogram Report 10 Special Investigations 2 Haemogram Report 1 Diff. Count (Mature Cells) 3 C-Reactive Protine 1 4 Urine Analysis 1 Physical Examination 4 Urine Analysis 8 Chemical Examination 4 Urine Analysis 10 Microscopic Examination of Centrifugalised Deposit 5 Haemogram Report 1 E.S.R. Thanks Bhavbhuti