首页 > 其他分享 >seqsever 查询多个表的条数,并以列的形式展现

seqsever 查询多个表的条数,并以列的形式展现

时间:2023-01-04 13:56:33浏览次数:41  
标签:COUNT case end when else 条数 HC seqsever 以列

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

标签:COUNT,case,end,when,else,条数,HC,seqsever,以列
From: https://www.cnblogs.com/yitian-lg/p/17024632.html

相关文章