I have data in the following format:
我有以下格式的数据:
1/1/2017 55
1/3/2017 23
1/3/2017 87
1/3/2017 45
1/4/2017 77
1/4/2017 90
1/4/2017 34
What is the fasted and most efficient way to query the database and output the average value for each date?
什么是查询数据库并输出每个日期的平均值的最快和最有效的方法?
2 个解决方案
#1
3
Your question is missing a lot of information and shows little or no effort in solving the problem.
您的问题缺少大量信息,并且很少或根本没有努力解决问题。
Regardless, you can use a SQL query like this to achieve the results you want:
无论如何,您可以使用这样的SQL查询来实现您想要的结果:
SELECT date_col, AVG(number_col) as average FROM table_name GROUP BY date_col
#2
-1
Try this
SELECT avg(value_field) FROM `table_name` group by date _field
#1
3
Your question is missing a lot of information and shows little or no effort in solving the problem.
您的问题缺少大量信息,并且很少或根本没有努力解决问题。
Regardless, you can use a SQL query like this to achieve the results you want:
无论如何,您可以使用这样的SQL查询来实现您想要的结果:
SELECT date_col, AVG(number_col) as average FROM table_name GROUP BY date_col
#2
-1
Try this
SELECT avg(value_field) FROM `table_name` group by date _field