Skip to content

Instantly share code, notes, and snippets.

@mikeminutillo
Created May 2, 2013 02:58
Show Gist options
  • Save mikeminutillo/5499869 to your computer and use it in GitHub Desktop.
Save mikeminutillo/5499869 to your computer and use it in GitHub Desktop.
An implementation of FizzBuzz in T-SQL
with t as (select 1 x union all select x + 1 from t where x < 100)
select case
when x % 3 = 0 AND x % 5 = 0 then 'FizzBuzz'
when x % 3 = 0 then 'Fizz'
when x % 5 = 0 then 'Buzz'
else CAST(x as varchar)
end
from t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment