sql统计查询 多个子语句输出一个结果
selectcount(*)asCountsfromTABLE.AinnerjoinTABLE.YonTABLE.A.AID=TABLE.Y.YIDselectcount...
select count(*) as Counts from TABLE.A inner join TABLE.Y on TABLE.A.AID = TABLE.Y.YID
select count(*) as Counts from TABLE.B inner join TABLE.Y on TABLE.A.BID = TABLE.Y.YID
select count(*) as Counts from TABLE.C inner join TABLE.Y on TABLE.A.CID = TABLE.Y.YID
这三句怎么合成一个? 展开
select count(*) as Counts from TABLE.B inner join TABLE.Y on TABLE.A.BID = TABLE.Y.YID
select count(*) as Counts from TABLE.C inner join TABLE.Y on TABLE.A.CID = TABLE.Y.YID
这三句怎么合成一个? 展开
1个回答
展开全部
把查询结果当成表
select a.Counts,b.Counts,c.Counts,a.Counts+b.Counts+c.Counts from
(select count(*) as Counts from TABLE.A inner join TABLE.Y on TABLE.A.AID = TABLE.Y.YID) a,
(select count(*) as Counts from TABLE.B inner join TABLE.Y on TABLE.A.BID = TABLE.Y.YID) b,
(select count(*) as Counts from TABLE.C inner join TABLE.Y on TABLE.A.CID = TABLE.Y.YID) c
select a.Counts,b.Counts,c.Counts,a.Counts+b.Counts+c.Counts from
(select count(*) as Counts from TABLE.A inner join TABLE.Y on TABLE.A.AID = TABLE.Y.YID) a,
(select count(*) as Counts from TABLE.B inner join TABLE.Y on TABLE.A.BID = TABLE.Y.YID) b,
(select count(*) as Counts from TABLE.C inner join TABLE.Y on TABLE.A.CID = TABLE.Y.YID) c
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询