Query to Search Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gjain12
    New Member
    • Jun 2008
    • 19

    Query to Search Data

    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
  • arjunsinghsamant
    New Member
    • Jan 2010
    • 3

    #2
    select * from tm where LASTUPDATETIMES TAMP in(select max( LASTUPDATETIMES TAMP) from tm)


    try this !!!

    Comment

    Working...