Created
September 28, 2020 02:56
-
-
Save jsrimr/4e2cfb9b433f8b306320ee5af11725ef to your computer and use it in GitHub Desktop.
db 중복 row 제거 쿼리
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE | |
FROM log_by_hour | |
WHERE id IN | |
( | |
SELECT id FROM (SELECT max(id) FROM log_by_hour where time BETWEEN FROM_UNIXTIME(1598927371) AND FROM_UNIXTIME(1598956231) GROUP BY instance_id, cmd_id, time, min, max, avg HAVING count(*) > 1) temp_table | |
) | |
and time BETWEEN FROM_UNIXTIME(1598927371) AND FROM_UNIXTIME(1598956231) | |
; | |
DELETE | |
FROM log_by_minute | |
WHERE id IN | |
( | |
SELECT id FROM (SELECT max(id) FROM log_by_minute where time BETWEEN FROM_UNIXTIME(1598927371) AND FROM_UNIXTIME(1598956231) GROUP BY instance_id, cmd_id, time, min, max, avg HAVING count(*) > 1) temp_table | |
) | |
and time BETWEEN FROM_UNIXTIME(1598927371) AND FROM_UNIXTIME(1598956231) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment