在两个日期之间获取数据并按个别日期对其进行分组

The title of the question might be a bit confusing but, essentially, what I'm trying to do is to retrieve DAILY data from a database that is in a certain date range using PHP.

For example, assume that I have a table like so:

ID  |  Value  |  Date
1   |  12     |  2017-01-01
2   |  8      |  2017-01-01
3   |  10     |  2017-01-02

I need to retrieve the daily total value.

TotalValue  |  Date
   20       |  2017-01-01
   10       |  2017-01-02

At the current time, I'm using a query that retrieves the total value for a given date and I do this for every single day in the date range. As you can imagine, this is not an efficient way of doing this, especially if you are retrieving records for the past year. I've not found an answer which closely resembles my problem.

you could use group by and between

   select sum(value) as TotalValue, Date
   from my_table 
   where date between '2017-01-01' and '2017-01-02'
   group by date