gpt4 book ai didi

Mysql 选择总计和名称

转载 作者:行者123 更新时间:2023-11-29 22:39:55 25 4
gpt4 key购买 nike

列出客户的名字、姓氏和花费的总金额(注意:花费的金额是订单小计 + 税费 + tblorder 表中的运输费用)。

我有这个代码(但值都是一样的:

Select CONCAT(firstname, ' ' ,lastname) as name, sum(ordersubtotal + ordertax + ordershipcost) as AmountSpent
From tblorder,tblcust
group by name

my queries

最佳答案

这应该可以做到:

Select CONCAT(firstname, ' ' ,lastname) as name, sum(ordersubtotal + ordertax + ordershipcost) as AmountSpent
From tblorder a
inner join tblcust b ON a.custId=b.custId
group by name;

您没有定义要加入表格的内容。

在您的代码风格中,这将是:

Select CONCAT(firstname, ' ' ,lastname) as name, sum(ordersubtotal + ordertax + ordershipcost) as AmountSpent
From tblorder a,tblcust b
where a.custId=b.custId
group by name;

(两者应该给出相同的结果)

关于Mysql 选择总计和名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29404364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com