Created
December 19, 2018 17:51
-
-
Save nickdotht/b568991e03be933b0593e736b5c94b10 to your computer and use it in GitHub Desktop.
This is the SQL that we use at dloHaiti to delete duplicated receipts introduced by the old POS app.
This file contains hidden or 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
set @kid = 102; | |
set @start_date = '2018-11-0'; | |
set @end_date = '2018-12-0'; | |
SET SQL_SAFE_UPDATES = 0; | |
DELETE FROM receipt | |
WHERE | |
id IN (SELECT | |
a.id | |
FROM | |
(SELECT | |
created_date, id | |
FROM | |
receipt | |
WHERE | |
created_date BETWEEN @start_date AND @end_date and date_format(created_date, "%h%i%s") <> "000000" | |
AND kiosk_id = @kid) AS a, | |
(SELECT | |
created_date, id | |
FROM | |
receipt | |
WHERE | |
created_date BETWEEN @start_date AND @end_date and date_format(created_date, "%h%i%s") <> "000000" | |
AND kiosk_id = @kid) AS b | |
WHERE | |
a.created_date = b.created_date | |
AND a.id < b.id); | |
SET SQL_SAFE_UPDATES = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment