sql 查询结果相加
SELECTcount(*)FROMsale_1110wheresalerid="01022";SELECTcount(*)FROMsale_1109wheresaler...
SELECT count(*) FROM sale_1110 where salerid ="01022";
SELECT count(*) FROM sale_1109 where salerid ="01022";
SELECT count(*) FROM sale_1108 where salerid ="01022";
SELECT count(*) FROM sale_1107 where salerid ="01022";
如将这几结果相加 展开
SELECT count(*) FROM sale_1109 where salerid ="01022";
SELECT count(*) FROM sale_1108 where salerid ="01022";
SELECT count(*) FROM sale_1107 where salerid ="01022";
如将这几结果相加 展开
4个回答
展开全部
sql查询结果相加。例子:select a.snum1 + b.snum2 from。(select sum(num1) snum1 from table1)a ,(select sum(num2) snum2 from table2)b。这样就能把a表和b表的结果相加看。(select sum(num1) snum1 from table1)a 用于统计table1表中num1字段的总和 其结果作为表a。(select sum(num2) snum2 from table2)b 用于于统计table2表中num2字段的总和 其结果作为表a。select a.snum1 + b.snum2 将a表和b表中的sum1和sum2相加。这样既可做查询结果相加。
展开全部
sql查询结果相加
例子:
select a.snum1 + b.snum2 from
(select sum(num1) snum1 from table1)a ,
(select sum(num2) snum2 from table2)b
这样就能把a表和b表的结果相加看
(select sum(num1) snum1 from table1)a 用于统计table1表中num1字段的总和 其结果作为表a
(select sum(num2) snum2 from table2)b 用于于统计table2表中num2字段的总和 其结果作为表a
select a.snum1 + b.snum2 将a表和b表中的sum1和sum2相加
这样既可做查询结果相加
例子:
select a.snum1 + b.snum2 from
(select sum(num1) snum1 from table1)a ,
(select sum(num2) snum2 from table2)b
这样就能把a表和b表的结果相加看
(select sum(num1) snum1 from table1)a 用于统计table1表中num1字段的总和 其结果作为表a
(select sum(num2) snum2 from table2)b 用于于统计table2表中num2字段的总和 其结果作为表a
select a.snum1 + b.snum2 将a表和b表中的sum1和sum2相加
这样既可做查询结果相加
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select sum(col) from (
SELECT count(*) col FROM sale_1110 where salerid ="01022" union all
SELECT count(*) col FROM sale_1109 where salerid ="01022" union all
SELECT count(*) col FROM sale_1108 where salerid ="01022" union all
SELECT count(*) col FROM sale_1107 where salerid ="01022")
SELECT count(*) col FROM sale_1110 where salerid ="01022" union all
SELECT count(*) col FROM sale_1109 where salerid ="01022" union all
SELECT count(*) col FROM sale_1108 where salerid ="01022" union all
SELECT count(*) col FROM sale_1107 where salerid ="01022")
更多追问追答
追问
select sum(col) from (
SELECT count(*) col FROM sale_1110 where salerid ="01022" union all
SELECT count(*) col FROM sale_1109 where salerid ="01022和select sum(col) from (
SELECT count(*) col FROM sale_1110 where salerid ="01021" union all
SELECT count(*) col FROM sale_1109 where salerid ="01021" union all
可以整编成,结果是二列
追答
??
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select qty=sum(qty) from
(
SELECT qty=count(*) FROM sale_1110 where salerid ="01022"
Union All
SELECT qty=count(*) FROM sale_1109 where salerid ="01022"
Union All
SELECT qty=count(*) FROM sale_1108 where salerid ="01022"
Union All
SELECT qty= count(*) FROM sale_1107 where salerid ="01022"
) a
(
SELECT qty=count(*) FROM sale_1110 where salerid ="01022"
Union All
SELECT qty=count(*) FROM sale_1109 where salerid ="01022"
Union All
SELECT qty=count(*) FROM sale_1108 where salerid ="01022"
Union All
SELECT qty= count(*) FROM sale_1107 where salerid ="01022"
) a
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询