Jeff Moden (2/21/2010)
I wouldn't set time limits on such tests... I'd just tell them to pretend they're writing code that will go into production and to give it their absolute best shot.
I agree with Jeff about not setting a time limit 'cause I remember when I last went for a job interview I was so nervous that I shaked all over and had they asked me this question then with a time limit I would have failed bitterly. Now just for the heck of it and for those young 'uns going for a job interview, I quickly did this test and to put it together took me 2 minutes ok, maybe 4, but here is my query and please, give me your take on this.
if isnull(object_id('tempdb..##rowtest'),0) <> 0 drop table ##rowtest
select top 100 identity(int,1,1) idkey into ##rowtest from syscolumns
select idkey, case when idkey % 3 = 0 then 'Fizz' else '' end [fizz],
case when idkey % 5 = 0 then 'Buzz' else '' end [buzz],
case when idkey%3 = 0 and idkey%5 = 0 then 'FizzBuzz' else '' end [fizzbuzz]
I give you the top 15 results.
idkey fizz buzz fizzbuzz
15 Fizz Buzz FizzBuzz
I can do all things through Christ who strengthens me. - Holy Bible
I am a man of fixed and unbending principles, the first of which is to be flexible at all times. - Everett Mckinley Dirkson (Well, I am trying. - Manie Verster)