with v1 as
(SELECT 客户名称,sum(金额) as 订单金额 FROM "订单详情表" group by 客户名称)
,
v2 as
(SELECT 客户名称,sum(发货金额) as 发货金额 FROM "发货单" group by 客户名称)
select v1.客户名称,v1.订单金额,v2.发货金额 from v1 inner join v2 on v1.客户名称=v2.客户名称;
with v1 as
(SELECT 客户名称,sum(金额) as 订单金额 FROM "订单详情表" group by 客户名称)
,
v2 as
(SELECT 客户名称,sum(发货金额) as 发货金额 FROM "发货单" group by 客户名称)
select v1.客户名称,v1.订单金额,v2.发货金额 from v1 inner join v2 on v1.客户名称=v2.客户名称;
影. 发表于 2021-10-4 23:37
SELECT A.金额,A.客户名称,B.总金额,C.应收金额 FROM "订单详情" A
INNER JOIN "发货单详情表" B
ON A ...
with cet1 as
(SELECT a.客户名称,sum(a.金额) as 订单金额 FROM "订单详情表" as a group by a.客户名称 where a.订单状态='确认'),
cet2 as
(SELECT b.客户名称,sum(b.发货金额) as 发货金额 FROM 发货单 as b group by b.客户名称)
select cet1.客户名称,cet1.订单金额,cet2.发货金额 from cet1 inner join cet2 on cet1.客户名称=cet2.客户名称;
SELECT A.客户名称,
sum(A.金额),
sum(B.总金额),
sum(C.应收金额)
FROM "订单详情" A
INNER JOIN "发货单详情表" B ON A.客户名称 = B.客户名称
INNER JOIN "收入账详情表" C ON A.客户名称 = C.付款方
where A.订单状态=“确认”
GROUP by A.客户名称