Tuesday, September 11, 2007

Pivot, UDF, FizzBuzz!

{

As I hit "publish" from my previous post on pivot tables, a thought struck me on another most excellent use for them. No, really - for the next job interview:

SELECT
    CASE
        WHEN I % 5 = 0 AND I % 3 = 0 THEN 'FizzBuzz'
        WHEN I % 3 = 0 THEN 'Fizz'
        WHEN I % 5 = 0 THEN 'Buzz'
        ELSE CONVERT(VARCHAR(2), I)
    END
FROM dbo.fnPivot(100)

}

No comments: