Last active
July 17, 2018 16:19
-
-
Save Hirurg103/d1a9f1b22ca6cb7b786ae769b38a7c4a to your computer and use it in GitHub Desktop.
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
# For mysql | |
SET @id:=1 | |
SELECT id, @num:=@num + 1 AS num | |
FROM ( | |
SELECT id FROM email_notifications ORDER BY created_at ASC | |
) AS t | |
HAVING MOD(num, 101) = 0; | |
# For postgresql | |
SELECT id FROM ( | |
SELECT id, (ROW_NUMBER() OVER(ORDER BY id DESC)) AS num FROM locations | |
) AS tn | |
WHERE num % 101 = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment