I'm setting up a MySQL query that sums values from a database and groups these by thresholds, so it only outputs the 'milestones' when certain values were reached.
The database looks like:
date - number
2018-12-01 - 500
2018-12-02 - 400
2018-12-03 - 300
2018-12-04 - 500
2018-12-05 - 400
etc.
Expected output:
Milestone 500 = 2018-12-01
Milestone 1000 = 2018-12-03
Milestone 2000 = 2018-12-05
etc.
Edit: The milestones should show what the first date was that a certain milestone was surpassed. So 2018-12-03 is the first date that 1000 was surpassed.
The 'milestones' won't be the same distance from each other in every occasion. So ideally I'm looking for a query that could combine SUM with IF and GROUP possibly?
I have been Googling for hours, but at a loss how I can do this, other than looping through all the results separately and counting the total values + if statements, which is resource consuming. If at all possible, I'd like to keep it within the query.
Thank you for your time!