我想创建一个 SQL 查询来显示产生最多收入的文章。 (在商店里)
Table = orderrader
rownumber articlenumber ordernumber price amount
1 11 1 8624 3
2 6 1 4794 2
3 17 1 8755 3
4 1 1 7803 1
5 16 1 8987 3
6 10 1 4575 3
7 4 1 8747 1
8 15 1 5439 3
9 11 2 8624 3
10 1 2 7803 1
最佳答案
以下 sql 语句将只返回一个具有最大收入的商品编号。
Select articlenumber, sum(price*amount) as totalincome
from orderrader
group by articlenumber
order by sum(price*amount) desc LIMIT 1
关于mysql - SQL 查询 "Find the article that has generated most income?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10579221/