You need to write a query that outputs a sequence of digits from 1 to 1000.
If the number is a multiple of three, then Fizz
is output instead of a number. If it is a multiple of five, then Buzz
, and if both three and five, then FizzBuzz
.
My pseudocode:
SELECT
CASE
WHEN (BETWEEN 1 AND 1000)% 3 = 0 THEN "Fizz",
WHEN (BETWEEN 1 AND 1000)% 5 = 0 THEN "Buzz",
WHEN (BETWEEN 1 AND 1000)% 5 = 0 AND WHEN (BETWEEN 1 AND 1000)% 3 = 0 THEN "FizzBuzz",
END
2
Answers
You could try this query
See demo here
Plain
case
statement:Array of options, cases cast to indices:
A combination of
coalesce()
with an array, keeps a static array without constructing it or prepending to it:coalesce()
of self-nullifying values:NATURAL LEFT JOIN
+SRF:demo