Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Most Recent record 2

Status
Not open for further replies.

TitleistDBA

IS-IT--Management
Apr 22, 2002
162
US
I have a table that has multiple clocknum's. I am looking for the most recent record for each clocknum. I am trying to get it by a datetime field called EFFDT. For some reason I am only getting back one record. Shouldn't this query return me a record for each clocknum?

SELECT a.clocknum, a.EFFDT
FROM employee_dump_tbl a, employee_dump_tbl b
WHERE a.clocknum = b.clocknum
and a.EFFDT = (SELECT MAX(EFFDT) from employee_dump_tbl)
and empl_action not in ('REC')

Thanks for the help.

 
Code:
SELECT clocknum
     , EFFDT
  FROM employee_dump_tbl as ZZ
 where EFFDT 
     = ( SELECT MAX(EFFDT) 
           from employee_dump_tbl
          where empl_action <> 'REC'
            and clocknum = ZZ.clocknum )
   and empl_action <> 'REC'

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top