Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have a table and I'm trying to remove all the duplicate and keep the
- the rows that has the latest datestamp.
- Here is the table:
- email address orgin_date new_opt_in_date datestamp
- 123@ax.tu 1/1/1900 1/1/1900 3/15/2016
- 123@ax.tu 1/1/1900 1/1/1900 3/15/2016
- iron_man@metrix.com 2/15/2015 3/5/2015 6/6/2017
- iron_man@metrix.com 2/15/2015 3/5/2015 7/6/2018
- sleep@dort.st 2/15/2015 3/5/201 7/6/2018
- sleep@dort.st 2/15/2015 3/5/201 5/6/2018
- I'm trying to keep only the data that has the recent datestamp, delete the
- rest and hope that the
- output will like this:
- email address orgin_date new_opt_in_date datestamp
- 123@ax.tu 1/1/1900 1/1/1900 3/15/2016
- iron_man@metrix.com 2/15/2015 3/5/2015 6/6/2017
- sleep@dort.st 2/15/2015 3/5/201 7/6/2018
- DELETE FROM `tablename`
- WHERE datestamp
- NOT IN (
- SELECT * FROM (
- SELECT MAX(datestamp) FROM tablename
- GROUP BY emailaddress
- )
- )
- but nothing it didn't work
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement