Link to home
Start Free TrialLog in
Avatar of MacNuttin
MacNuttinFlag for United States of America

asked on

Get the newest records of each type

I have one table with dated records of 4 different types by employee. I need to query the newest record of each type by employee

Example:
emp    type  result  date
1           1       -1        03/03/07
1           1       0          03/03/06
1           2        0         03/03/05
1           3        1         03/01/07
1           4        0         03/03/07

I need:
emp    type  result  date
1           1       -1        03/03/07
1           2        0         03/03/05
1           3        1         03/01/07
1           4        0         03/03/07
Avatar of QPR
QPR
Flag of New Zealand image

select max(date), type
from thetable
group type
correction...

group by type
Grrr corection again...
My head must still be on the pillow. I hate Monday morning :)
Ignore my entire response, now that I look at it properly it only returns 1 row.
Sorry :(
ASKER CERTIFIED SOLUTION
Avatar of opho
opho

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MacNuttin

ASKER

Thanks opho. These queries are hard for me sometimes I get stuck on them and rely on my experts-exchange friends.
Avatar of opho
opho

cool, MacNuttin...

I hear ya!