I have this table with employee contract records.
+----+---------------------------+
| id | start| end | employee |
+----+---------------------------+
| 8 | 2016 | 2017 | 777 |
| 7 | 2014 | 2015 | 777 |
| 6 | 2012 | 2013 | 777 |
| 5 | 2010 | 2011 | 777 |
| 3 | 2016 | 2017 | 666 |
| 4 | 2014 | 2015 | 666 |
| 2 | 2012 | 2013 | 666 |
| 1 | 2010 | 2011 | 666 |
+----+---------------------------+
I'm having difficulty getting the latest contract per employee.
The query should print:
+----+-----------------+
| id | start| employee |
+----+-----------------+
| 8 | 2016 | 777 |
| 3 | 2016 | 666 |
+----+-----------------+
I have tried so far:
SELECT
MAX(start)
,id
,employee
FROM contract
GROUP BY employee
but that gives me id that doesn't correspond to the record.