-
-
Save arossouw/d4f2e7d3086e2a444f647c2632ae3343 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
WITH RECURSIVE fizz_buzz (sequence, modulo_3, modulo_5) AS ( | |
SELECT 1, CAST('' AS CHAR(4)), CAST('' AS CHAR(5)) | |
UNION ALL | |
SELECT sequence + 1, | |
IF(MOD(sequence + 1, 3) = 0, 'Fizz', ''), | |
IF(MOD(sequence + 1, 5) = 0, 'Buzz', '') | |
FROM fizz_buzz | |
WHERE sequence < 100 | |
) | |
SELECT | |
IF(CONCAT(modulo_3, modulo_5) = '', sequence, CONCAT(modulo_3, modulo_5)) AS fizzbuzz | |
FROM fizz_buzz; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment