We help IT Professionals succeed at work.
Get Started

SQL-SubQuery to remove duplicates

Last Modified: 2014-11-14
I have the below query:
select * from expeditetbl1 ex 
left outer join exp_dummytbl expd on ex.program=expd.pgm_codes
 ex.open_qty <>0
and vendor_code='HAL601' and po_num='41309844'
and emp_num='092'

select * from exp_dummytbl where emp_num='092' and pGM_CODES='661'

Open in new window

The second query has duplicates for that combination so when I do the left join in the first query its returning 2 rows.How can I modify the first query to a subquery so that the duplicates are eliminated.
Watch Question
This problem has been solved!
Unlock 3 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE