'Getting multiple date ranges between SQL query and adding up the data accordingly
I need to select a certain range of dates after I have already completed the query SELECT * FROM <DB>.
For example:
var (date string
views int
impressions int)
for query.Next() {
err := query.Scan(&date, &views, &impressions)
// handle the err
// get the range of dates for each month
// add up all the views and impressions in that specific range
}
The 'date' var will obviously be all of the dates in the database query.
Dates are formatted as: 2017-10-01 (October 1st as an example) and there are about 300 in October and 100 in November.
From here, I need to add up all the values (views and impressions), but only per date range.
So I would get something like:
2017-10-01 to 2017-10-31 has 54 impressions2017-10-01 to 2017-10-07 has 5 impressions as an example.
Any idea how I'd come about this issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
