Here's the scenario. I have employees and they evaluated yearly for different categories. I need: the full row of the latest evaluation for each category.
Example:
Employee Table:
EmpID  Name
454    John
Evals Table:
id EmpID  Category  EvalDate     Note
1  454       A      2016-01-01   Excellent
2  454       A      2017-02-15   Not so good
3  454       B      2016-01-01   Poor
4  454       B      2017-02-01   Good
I need a query that returns the latest eval (the full row) for each category:
EmpID  Category  EvalDate     Note
454       A      2017-02-15   Not so good
454       B      2017-02-01   Good
My query so far:
SELECT 
    evals.EmpID,
    evals.Category,
    evals.Note,
    MAX(evals.EvalDate) as LatestEval
FROM
    evals
WHERE 
    evals.EmpID = 454
GROUP BY
    evals.Category
This unfortunately returns the latest date for each category but the note field from older evals.
 
    