I need to show results grouped by price (from, to)
Values of my DB:
articulo | fecha | precio
pelota |2018-11-10 | 10
pelota |2018-11-11 | 10
pelota |2018-11-12 | 11
pelota |2018-11-13 | 11
pelota |2018-11-14 | 11
raqueta |2018-11-10 | 100
raqueta |2018-11-11 | 100
raqueta |2018-11-12 | 110
raqueta |2018-11-13 | 110
raqueta |2018-11-14 | 110
The result I need would be to show like this:
List price:
pelota : desde 2018-11-10 al 2018-11-11 $ 10
pelota : desde 2018-12-10 al 2018-11-14 $ 11
raqueta: desde 2018-11-10 al 2018-11-11 $ 100
raqueta: desde 2018-12-10 al 2018-11-14 $ 110
The only thing I can think of is to find the minimum and maximum date and make a for loop from the minimum date to the maximum date, increasing by 1 day. takes the initial value of the price saved in the array and compares in position -1 to the current one.