SQL Select Max Help?
Hello,
Hoping someone can help me with this...I'm pulling data from 2 tables: Employment and Job. The Job table has multiple effective dates (effdt), so when I run the statement, I'm getting ALL the rows, and I want only the most recent record. I've been playing around with "select max" and I can't seem to get it right....can you?? Also, I had to add distinct to the select, otherwise each effdt was appearing twice. Thanks in advance for your help!
select distinct e.emplid, e.check_voucher_ind, j.empl_status, j.effdt
from ps_employment e, ps_job j
where e.emplid = j.emplid
and j.emplid = '105917'
order by check_voucher_ind
Results are:
EMPLID Check_voucher_ind Status effdt
105917 N A 11/03/2003 00:00:00
105917 N A 06/03/2004 00:00:00
105917 N A 07/03/2004 00:00:00
105917 N A 07/02/2005 00:00:00
105917 N A 09/28/2005 00:00:00
105917 N A 12/05/2005 00:00:00
105917 N A 07/01/2006 00:00:00
105917 N A 07/07/2006 00:00:00
105917 N A 09/19/2006 00:00:00
105917 N A 11/04/2006 00:00:00
105917 N A 06/30/2007 00:00:00
105917 N P 05/18/2004 00:00:00
__________________
Until the 20th century, reality was everything humans could touch, smell, see, and hear. Since the initial publication of the charted electromagnetic spectrum, humans have learned that what they can touch, smell, see, and hear is less than one millionth of reality
|