简体   繁体   English

最大和总和 mysql

[英]Max And Sum mysql

I've to get all the orders from one customer, then get the sum of the orders and then get the max order.我必须从一位客户那里获得所有订单,然后获得订单总和,然后获得最大订单。 I can't use order by and limit.我不能使用 order by 和 limit。 I got the result but i can't get the make sum and max work properly我得到了结果,但我无法得到 make sum 和 max 正常工作

here is my current query:这是我当前的查询:

SELECT SUM(Qty * UnitPrice) AS Total FROM `Details`
WHERE ONo IN (
    SELECT Orders.Ono
    FROM Orders, Customers
    WHERE Customers.FName = 'Charles' AND Customers.LName = 'Xavier' AND Customers.CNo = Orders.CNo
    GROUP BY Orders.ONo
)
GROUP BY ONo

Total
7.50
20.99
54.47
49.98
8.00

请尝试:

SELECT MAX(Total) as MaxTotal FROM (<your query comes here>) AS T

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM