Hi All,
I have a table in which there is no primary key.
It can contain multiple values for a single id.
e.g. suppose the structure of the table is :
empid emptype lastupdatetimes tamp
1 temp 2009-12-01
2 perm 2009-12-02
1 perm 2009-12-02
So, I have to write a query that should return the row that has the latest timestamp. e.g. in the case defined above, I need the result as
1 perm 2009-12-02
2 perm 2009-12-02
I have tried select empid,emptype,m ax(lastupdateti mestamp) from table group by empid but it returns
1 temp 2009-12-02
2 perm 2009-12-02
Any pointers can be helpful.
Thanks
Gaurav
I have a table in which there is no primary key.
It can contain multiple values for a single id.
e.g. suppose the structure of the table is :
empid emptype lastupdatetimes tamp
1 temp 2009-12-01
2 perm 2009-12-02
1 perm 2009-12-02
So, I have to write a query that should return the row that has the latest timestamp. e.g. in the case defined above, I need the result as
1 perm 2009-12-02
2 perm 2009-12-02
I have tried select empid,emptype,m ax(lastupdateti mestamp) from table group by empid but it returns
1 temp 2009-12-02
2 perm 2009-12-02
Any pointers can be helpful.
Thanks
Gaurav
Comment