Last active
October 15, 2018 21:50
-
-
Save erchn/5f8cc509b4f9b55371d2c2e2c3f35994 to your computer and use it in GitHub Desktop.
Athena FizzBuzz
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
SELECT val, | |
CASE | |
WHEN by5+by3 = 0 THEN 'FizzBuzz' | |
WHEN by5 = 0 THEN 'Fizz' | |
WHEN by3 = 0 THEN 'Buzz' | |
ELSE cast(val AS varchar) | |
END AS fizzbuzz_test | |
FROM | |
(SELECT val, | |
mod(val, 5) AS by5, | |
mod(val, 3) AS by3 | |
FROM (values (15), (10), (9), (17)) AS t (val)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment