SQL 2个查询结果合并成一个查询结果+多列
select b.FSupplyID,sum(FConsignAmount) as money from ICStockBillEntry a left join ICStockBill b on a.FInterID=b.FInterID
where b.FSupplyID='31890'
group by b.FSupplyID order by money
select FSupplyID,count(*) as money from ICStockBill where FSupplyID='31890' group by FSupplyID order by FSupplyID
--------------
31890127899.00
318903
---------------------
2个查询语句,返回的结果分别如上,能否整合成一条
31890127899.00 3
因为一个是订单表+订单明细表,取出某个客户消费金额
一个是直接取出客户购买的订单次数,使用UNION不好直接查出。。
谢谢了。
[解决办法]
select b.FSupplyID,a.money,b.money1 from
(
select b.FSupplyID,sum(FConsignAmount) as money from ICStockBillEntry a left join ICStockBill b on a.FInterID=b.FInterID
where b.FSupplyID='31890'
group by b.FSupplyID
)a
inner join
(
select FSupplyID,count(*) as money1 from ICStockBill where FSupplyID='31890'
group by FSupplyID
)b
on a.FInterID=b.FInterID