Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql “SQL查询”;找到收入最多的文章;_Mysql_Sql - Fatal编程技术网

Mysql “SQL查询”;找到收入最多的文章;

Mysql “SQL查询”;找到收入最多的文章;,mysql,sql,Mysql,Sql,我想做一个SQL查询,向我显示产生最多收入的文章。(在商店里) 这应该可以做到,我在自己的数据库中进行了检查。它只会给出最高价格*金额的一个 SELECT articlenumber, SUM(price*amount) AS income FROM table GROUP BY articlenumber ORDER BY income DESC 这应该可以做到,我在自己的数据库中进行了检查。它将只给出价格*金额最高的一个下面的sql语句将只返回一个最大收入的articlenumber SE

我想做一个SQL查询,向我显示产生最多收入的文章。(在商店里)

这应该可以做到,我在自己的数据库中进行了检查。它只会给出最高价格*金额的一个

SELECT articlenumber, SUM(price*amount) AS income
FROM table
GROUP BY articlenumber
ORDER BY income DESC

这应该可以做到,我在自己的数据库中进行了检查。它将只给出价格*金额最高的一个

下面的sql语句将只返回一个最大收入的articlenumber

SELECT articlenumber, SUM(price*amount) AS income
FROM table
GROUP BY articlenumber
ORDER BY income DESC
Select  articlenumber, sum(price*amount) as totalincome
from orderrader
group by articlenumber 
order by sum(price*amount) desc LIMIT 1

下面的sql语句将只返回一个最大收入的articlenumber

Select  articlenumber, sum(price*amount) as totalincome
from orderrader
group by articlenumber 
order by sum(price*amount) desc LIMIT 1

结果中只需要一个ariclenumber,结果中只需要一个ariclenumber
Select  articlenumber, sum(price*amount) as totalincome
from orderrader
group by articlenumber 
order by sum(price*amount) desc LIMIT 1