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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Find More Than One Record?

Status
Not open for further replies.

VAST39

Programmer
Sep 21, 2012
26
US
Hi everyone,

I'm a bit stumped on this one, but I think I'm on the right track. I need to run a query that finds employees who are currently have more than one employer. The employer is referenced by an agency number.


Sample Table looks like this:

EMPR TABLE

SSN AGENCY LAST EMPLOYED DATE

123456789 4533 NULL
123456789 2345 NULL


So this sample shows a person who is working in two different agencies. A NULL date means it is an active employment.


How do I write a query to look for only SSNS that meet this condition? I've done this before years ago, and I believe I used a self-join, but I'm not 100% sure if this is right:


Code:
select * from empr a,
              empr b
              
 where a.ssn = b.snn
 and a.agency <> b.agency
 and LAST EMPLOYED DATE is NULL


Am I on the right track?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top