Вы можете достичь желаемого результата с помощью следующего скрипта, но нуждаетесь в некоторой корректировке в своем отчете, например, заменяя District_name и Training_type в части отчета. Условие будет следующим: если District_Name = 'ZZZZZ', то перед отображением замените оба параметра: district_name и training_type на ''.
WITH Tab1(district_name,training_type,male_participants,female_participants,total_participants)
AS
(
SELECT 'Jhal MAgsi','CMST',10,20,30 UNION ALL
SELECT 'Khuzdar','CMST',5,5,10 UNION ALL
SELECT 'Killa Abdullah','CMST',15,15,30 UNION ALL
SELECT 'Jhal MAgsi','CAT',1,2,3 UNION ALL
SELECT 'Khuzdar','CAT',14,20,34 UNION ALL
SELECT 'Loralai','CAT',100,250,350 UNION ALL
SELECT 'Pishin','CAT',1,1,2 UNION ALL
SELECT 'Jhal MAgsi','LN',3,3,6 UNION ALL
SELECT 'Khuzdar','LN',9,100,109 UNION ALL
SELECT 'Loralai','LN',200,50,250 UNION ALL
SELECT 'Jhal MAgsi','LMST',5,8,13 UNION ALL
SELECT 'Khuzdar','LMST',9,5,14
)
SELECT district_name,training_type,male_participants,female_participants,total_participants
FROM Tab1 T1
UNION ALL
SELECT 'ZZZZZ' district_name,
training_type,
SUM(T1.male_participants) male_participants,
SUM(T1.female_participants) female_participants,
SUM(T1.total_participants) total_participants
FROM tab1 T1
GROUP BY training_type
ORDER BY 2,1
Выход -
district_name training_type male_participants female_participants total_participants
Jhal MAgsi CAT 1 2 3
Khuzdar CAT 14 20 34
Loralai CAT 100 250 350
Pishin CAT 1 1 2
ZZZZZ CAT 116 273 389
Jhal MAgsi CMST 10 20 30
Khuzdar CMST 5 5 10
Killa Abdullah CMST 15 15 30
ZZZZZ CMST 30 40 70
Jhal MAgsi LMST 5 8 13
Khuzdar LMST 9 5 14
ZZZZZ LMST 14 13 27
Jhal MAgsi LN 3 3 6
Khuzdar LN 9 100 109
Loralai LN 200 50 250
ZZZZZ LN 212 153 365