Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH
- redundant AS (
- SELECT
- id,
- MAX(updated_at) AS updated_at,
- COUNT(*) AS counter
- FROM
- t1
- GROUP BY
- id
- HAVING
- counter >= 2)
- DELETE
- FROM
- t1
- WHERE
- id IN (redundant.id)
- AND updated_at NOT IN (redundant.updated_at )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement