I need a mysql query who want to do this
initial data
id | from_id | to_id | route_id | price
1 | 360 | 415 | 204 | 100
2 | 372 | 458 | 204 | 100
3 | 395 | 372 | 204 | 100
4 | 395 | 372 | 204 | 100
5 | 395 | 372 | 205 | 100
6 | 395 | 372 | 204 | 100
7 | 395 | 458 | 210 | 100
8 | 395 | 458 | 210 | 100
result data
id | from_id | to_id | route_id | price
1 | 395 | 372 | 204 | 100 // because his periodicity is 3
2 | 395 | 458 | 210 | 100 // because his periodicity is 2
3 | 395 | 372 | 205 | 100
4 | 360 | 415 | 204 | 100
5 | 372 | 458 | 204 | 100
Is something like that
SELECT * FROM myTable GROUP BY from_id,to_id,route_id
but i don’t know how to add COUNT or MAX and ORDER BY
Thanks
Your final table of IDs looks more like a sequential, but that doesn’t correlate with original data and doesn’t appear to serve any purpose otherwise.