SHARE
TWEET

Untitled

a guest Jun 24th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH
  2.   redundant AS (
  3.   SELECT
  4.     id,
  5.     MAX(updated_at) AS updated_at,
  6.     COUNT(*) AS counter
  7.   FROM
  8.     t1
  9.   GROUP BY
  10.     id
  11.   HAVING
  12.     counter >= 2)
  13. DELETE
  14. FROM
  15.   t1
  16. WHERE
  17.   id IN (redundant.id)
  18.   AND updated_at NOT IN (redundant.updated_at )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top