We help IT Professionals succeed at work.

Need help eliminating duplicates and keeping the last record

130 Views
Last Modified: 2018-09-07
Need a SQL statement that eliminates duplicates and chooses the last record entered.

Ex. WO1002421 has two entries. I want to keep the record of the last person Wilmer Tamayo-Sanchez.

This statement below is what I am using but as unfortunately, it still brings in duplicates.  
SELECT MAX(WO_NUMBER) as wo_number
	  ,FIRST_NAME
      ,LAST_NAME
  FROM BA_VIEW_WO_LABOR
WHERE SKILL NOT LIKE '%INSPECTOR'
GROUP BY WO_NUMBER
      ,FIRST_NAME
      ,LAST_NAME
	  having count(*)>1
ORDER BY WO_NUMBER 

Open in new window

Capture.JPG
Comment
Watch Question

Database Developer & Administrator
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2012
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
johnsoneSenior Oracle DBA
CERTIFIED EXPERT

Commented:
How do you define "last one"?  Typically, there is a date field or something like that to order by to determine which one is first or last.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.