Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:14
Show Gist options
  • Save st98/612f692861e19e1bfe23 to your computer and use it in GitHub Desktop.
Save st98/612f692861e19e1bfe23 to your computer and use it in GitHub Desktop.
SQL で FizzBuzz。
with recursive t(x, s) as (
select 0, NULL union all select x + 1,
case
when (x + 1) % 15 = 0 then 'FizzBuzz'
when (x + 1) % 3 = 0 then 'Fizz'
when (x + 1) % 5 = 0 then 'Buzz'
else (x + 1)
end
from t limit 1, 100
) select s from t;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment