Link to home
Get AccessLog in
Avatar of maximus1974
maximus1974

asked on

Need help eliminating duplicates and keeping the last record

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
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
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.