+ 2

PLEASE HELP! SQL insert into, deleting duplicate rows that have some matching info and same ID

SCENARIO: I have a master file of customer orders. I need to import some of the columns into the customers table(name, address, etc) and auto-create a customer ID. Then import the rest of the columns from the master file into the orders table(date, agent ID, joining with the newly created customer ID). The process works fine except for... MY PROBLEM IS: There are some rows that are entered twice that have minor differences. For example: (name, phone, address, subscription number) ROW 1: "John, Smith, 3232112111, 123 2nd St #4, 5shdm67h5" ROW 2: "JOHN, SMITH, 13232112111, 123 Second Street Apt. 4, 5shdm67h5". The last value of each row is their "subscription number" which is the unique key. The customer is obviously the same, but the two entries have the values for name, phone, and address entered differently. Using distinct, it is creating two customer IDs for each row of John Smith. I need DISTINCT to be based only on subscription number and ignore the other columns completely.

18th Jul 2019, 11:13 PM
Michael Hiatt
Michael Hiatt - avatar
0 Antworten