gpt4 book ai didi

mysql - 计算每个销售代表的佣金

转载 作者:行者123 更新时间:2023-11-29 19:49:02 25 4
gpt4 key购买 nike

有点卡在这个上了..

问题:计算每位销售代表的佣金,假设佣金为订单成本的 5%。按员工姓氏和名字排序。

对于这个数据库.. http://richardtwatson.com/dm6e/images/general/ClassicModels.png

这是我所拥有的..

SELECT salesRepEmployeeNumber, amount * orderNumber AS commission, 
CONCAT(firstName, ' ', lastName) AS sales_rep
FROM Customers, Payments, Employees, Orders
WHERE Payments.customerNumber= Customers.customerNumber
AND (amount * orderNumber) * .05`

`

但显然这个查询没有任何结果!

TIA

最佳答案

好吧,我想我可能已经弄清楚了..如果有更简单的方法,请告诉我!

SELECT Customers.salesRepEmployeeNumber, CONCAT(firstName, ' ', lastName) AS Employee, (amount*5)/100 AS commission
FROM Customers, Payments, Employees
WHERE Payments.customerNumber= Customers.customerNumber
ORDER BY lastName, firstName;

关于mysql - 计算每个销售代表的佣金,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40879781/

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