[英]MYSQL MAX and Min query
Hi could someone help me with this problem for my college homework assignment 嗨,有人可以帮我解决这个问题吗?
cars
Make MadeIn Sales
GM 2005 100
GM 2006 1200
GM 2007 600
What I have to do is work out the greatest increase in Sales between 2005 and 2007 and display this value and the Make 我要做的是找出2005年至2007年间的最大销售额增长,并显示此价值和品牌价值
I think I have the answer to the increase but cannot display the 'Make' to go along side the increase in sales (growth) 我认为我可以解决增加的问题,但无法显示“使”与销售额(增长)的增长并驾齐驱
This is what I have so far: 这是我到目前为止的内容:
select max(growth)
from (
select make, max(sales) - min(sales) as growth
from cars group by make) as carsales,cars;
I need the result to show: 我需要显示结果:
Make Growth
GM 1100
The results of your query come from your first select statement 查询结果来自您的第一个选择语句
I would show you but I don't want to give to much away, you'll learn more that way. 我会告诉你,但我不想付出太多,您会通过这种方式学到更多。
Note that the query you have now will give you the total growth (or loss). 请注意,您现在拥有的查询将为您提供总增长(或亏损)。 It won't give you the growth in one year.
它不会给您一年的增长。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.