I need to eliminate the duplicates of a table in snowflake, but there's an issue that I can't solve.
I'm using this code:
DELETE FROM int_ga.DIM_table
WHERE id , in (
SELECT id
FROM (
SELECT SK_DIM_CHANNEL
,ROW_NUMBER() OVER (PARTITION BY id , name ORDER BY id ) AS rn
FROM int_ga.DIM_table
)
WHERE rn > 1
);
Imagine this example table:
| id | name |
|---|---|
| 1 | example1 |
| 1 | example1 |
| 2 | example2 |
| 3 | example3 |
| 3 | example3 |
It's supposed to be like this:
| id | name |
|---|---|
| 1 | example1 |
| 2 | example2 |
| 3 | example3 |
But in the end, it eliminates both of the duplicates. I can't make it only delete one of them.