Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.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 选择每年的平均价格_Mysql_Sql_Dataset_Aggregate_Grouping - Fatal编程技术网

Mysql 选择每年的平均价格

Mysql 选择每年的平均价格,mysql,sql,dataset,aggregate,grouping,Mysql,Sql,Dataset,Aggregate,Grouping,我有这样一个数据集: year, average_price 1993, 222.2220, 1993, 2333.333 1993, 333.345 1994, 3445.444 1994, 4493.33 1995, 66005.33 1995, 33994.333 1995, 33993.333, 1996, 33884.33 我需要在此数据集中显示每年的平均价格 这是否意味着我可以计算平均价格的总和,然后按年份分组计算,就像这样 select year as y, sum(averag

我有这样一个数据集:

year, average_price
1993, 222.2220,
1993, 2333.333
1993, 333.345
1994, 3445.444
1994, 4493.33
1995, 66005.33
1995, 33994.333
1995, 33993.333,
1996, 33884.33
我需要在此数据集中显示每年的平均价格

这是否意味着我可以计算平均价格的总和,然后按年份分组计算,就像这样

select year as y, sum(average_price) as avg_price from table group by y

谢谢。

你可以试试这样的

select [year] as y, avg(average_price) as avg_price 
from Ttable 
group by [year];

提示:如果您想要平均价格,请使用
AVG()
。这是否回答了您的问题@GordonLinoff平均价格列是该条目的实际平均价格值,我只需要显示每年的所有平均价格。我需要当年所有平均价格的总和,而不是按年份分组。我希望你明白这一点,谢谢。