I have a table with columns latitude and longitude. In most cases the value extends past the decimal quite a bit: -81.7770051972473 on the rare occasion the value is like this: -81.77 for some records.
How do I find duplicates and remove one of the duplicates for only the records that extend beyond two decimal places?
Using some creative
substring,float, andcharindexlogic, I came up with this:Before running, try
select *in lieu ofdelete l1first to make sure you’re deleting the right rows.I should note that this worked on SQL Server using functions I know exist in MySQL, but I wasn’t able to test it against a MySQL instance, so there may be some little tweaking that needs to be done. For example, in SQL Server, I used
charindexinstead ofinstr, but both should work similarly.