select sum(a) a,sum(b) b,sum(c) c,SUM(d) d,sum(a1) a1,sum(b1) b1,sum(c1) c1,SUM(d1) d1
from
(
select case x when 'a' THEN y else 0 end a,
case x when 'b' THEN y else 0 end b,
case x when 'c' THEN y else 0 end c,
case x when 'd' THEN y else 0 end d,
case x when 'a1' THEN y else 0 end a1,
case x when 'b1' THEN y else 0 end b1,
case x when 'c1' THEN y else 0 end c1,
case x when 'd1' THEN y else 0 end d1
from
(
sELECT 'a' x,COUNT(*) y from NCR_HC_FAB2INLINE a
union all
sELECT 'b' x,COUNT(*) y from NCR_HC_FAB3INLINE b
union all
sELECT 'c' x,COUNT(*) y from NCR_HC_FAB2Offline c
union all
sELECT 'd' x,COUNT(*) y from NCR_HC_FAB3Offline d
UNION ALL
sELECT 'a1' x,COUNT(*) y from NCR_HC_FAB2INLINE a1 WHERE isnull(ifcf,'0')!='0'
union all
sELECT 'b1' x,COUNT(*) y from NCR_HC_FAB3INLINE b1 WHERE isnull(ifcf,'0')!='0'
union all
sELECT 'c1' x,COUNT(*) y from NCR_HC_FAB2Offline c1 WHERE isnull(ifcf,'0')!='0'
union all
sELECT 'd1' x,COUNT(*) y from NCR_HC_FAB3Offline d1 WHERE isnull(ifcf,'0')!='0'
) as w
) as y