I have two tables Locations and competitors, i want to get the latest row from locations for each competitor order by timestamp in mysql. I don't know how to combine aggregate with non aggregate without changing the sql mode 'ONLY_FULL_GROUP_BY'
Tabels looks like
Location
| lng | lat | competitor_id | timestamp |
| 99.99999 | 88.99999| 1666 |2021-07-29 10:40
| 65.99999 | 36.99999| 1555 |2021-07-29 10:12
| 35.99999 | 42.99999| 1888 |2021-07-29 10:28
| 28.99999 | 58.99999| 1666 |2021-07-29 10:17
| 47.99999 | 32.99999| 1555 |2021-07-29 10:42
| 22.99999 | 15.99999| 1888 |2021-07-29 10:05
Competitors
| Name | team | competitor_id
| Artial Dedino | Scuderia | 1666
| Naruto Belica | Redb| 1555
| Maranelino Kita | Sport| 1888
I try
SELECT c.`name`,l.lat,l.lng,l.timestamp
FROM competitors as c
INNER JOIN locations as l ON l.competitor_id = c.number
GROUP BY c.number
ORDER BY l.timestamp DESC
Need result like
| Naruto Belica | Redb| 2021-07-29 10:42
| Artial Dedino | Scuderia | 2021-07-29 10:40
| Maranelino Kita | Sport| 2021-07-29 10:28