我从一个客户处获得所有订单,然后获得订单总和,然后获得最大订单。 我不能使用order by和limit。 我得到了结果,但我无法获得总和和最大值正常工作
这是我当前的查询:
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
答案 0 :(得分:0)
请尝试:
SELECT MAX(Total) as MaxTotal FROM (<your query comes here>) AS T