Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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;
@arossouw

This comment has been minimized.

Copy link

@arossouw arossouw commented May 4, 2019

Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment