gpt4 book ai didi

mysql - SQL 查询 "Find the article that has generated most income?"

转载 作者:太空宇宙 更新时间:2023-11-03 11:07:57 24 4
gpt4 key购买 nike

我想创建一个 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/

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