can we get this guy banned from the forums?????

  • derek.colley (5/24/2012)


    Oh god, not another bunfight. My last post started a row between two MVPs.

    Nah... these things are fun and frequently educational for everyone because MVPs tend to pull out all the stops. 😀

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Lynn Pettis (5/24/2012)


    Cadavre (5/24/2012)


    Fizzbuzz is your evil interview? Really? It's as old as dirt (as are the solutions) 😛

    WITH t1 AS (SELECT 1 N UNION ALL SELECT 1 N),

    t2 AS (SELECT 1 N FROM t1 x, t1 y),

    t3 AS (SELECT 1 N FROM t2 x, t2 y),

    tally AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS number

    FROM t3 x, t3 y)

    SELECT t.number,

    CASE WHEN t.number%3 = 0 AND t.number%5 = 0

    THEN 'FizzBuzz'

    WHEN t.number%3 = 0

    THEN 'Fizz'

    WHEN t.number%5 = 0

    THEN 'Buzz'

    ELSE CONVERT(VARCHAR(3),t.number)

    END AS result

    FROM tally t

    WHERE t.number <= 100 AND t.number >= 1;

    --edit--

    Oh, and as for banning - I say "no". You don't have to answer them, you can ignore anyone you wish. If people start getting banned for asking "basic questions", where does the line get drawn? Who draws the lines?

    Here is my FizzBuzz solution:

    WITH

    E1(N) AS (

    SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL

    SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL

    SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1

    ), --10E+1 or 10 rows

    E2(N) AS (SELECT 1 FROM E1 a, E1 b), --10E+2 or 100 rows

    E4(N) AS (SELECT 1 FROM E2 a, E2 b), --10E+4 or 10,000 rows max

    cteTally(N) AS (

    SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM E4

    )

    select

    isnull(nullif(case when N % 3 = 0 then 'Fizz' else '' end + case when N % 5 = 0 then 'Buzz' else '' end, ''),cast(N as varchar))

    from

    cteTally

    where

    N <= 100

    Brevity and obscurity

    declare @ char(3)

    set @=0

    while @<100

    begin

    set @=@+1

    print

    case when @%15=0 then 'FizzBuzz'

    when @%3=0 then 'Fizz'

    when @%5=0 then 'Buzz'

    else @ end

    end

  • Koen Verbeeck (5/24/2012)


    Sean Lange (5/24/2012)


    Koen Verbeeck (5/24/2012)


    Sean Lange (5/24/2012)


    Always keep in mind that the questions you find super easy today are a great chance for some less experienced folks to start answering. This helps to give them some confidence. We need this type of thing to maintain this place over the long haul.

    I say "Up the Basic Questions"!!!!

    In my opinion, there's a big difference between basic questions of people who are trying to learn, or interview questions of someone too lazy to do research and who's trying to cheat through the interview.

    This is true. It is also incredibly obvious when these types of questions arise. It is up to the individual to decide not to answer, or dog pile the OP as the thread in question does. 😛

    And any interviewer who has conducted more than 1 interview will be able to through a smokescreen, especially one as obvious this person's. Sheesh a simple select statement might prove challenging for that person. That still is no reason to ban them. It just goes against the nature of this site entirely.

    Just to be clear, I don't want to ban him.

    I do however reserve the right to be annoyed by interview questions 😀

    Not only can you reserve that right but you have to make room next to me with the annoyance. Not only the right to be annoyed but the right to vent that annoyance loudly!!!!

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Michael Valentine Jones (5/24/2012)


    Brevity and obscurity

    declare @ char(3)

    set @=0

    while @<100

    begin

    set @=@+1

    print

    case when @%15=0 then 'FizzBuzz'

    when @%3=0 then 'Fizz'

    when @%5=0 then 'Buzz'

    else @ end

    end

    If I was asked this in an interview, I'd produce the solution I gave first then this one second. I always try and produce two or more solutions to every interview problem I'm given.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Koen Verbeeck (5/24/2012)


    What!? You want to ban the biggest comedian of this entire forum?

    😀 😎 :hehe:

    true

    MVDBA

  • Cadavre (5/25/2012)


    Michael Valentine Jones (5/24/2012)


    Brevity and obscurity

    declare @ char(3)

    set @=0

    while @<100

    begin

    set @=@+1

    print

    case when @%15=0 then 'FizzBuzz'

    when @%3=0 then 'Fizz'

    when @%5=0 then 'Buzz'

    else @ end

    end

    If I was asked this in an interview, I'd produce the solution I gave first then this one second. I always try and produce two or more solutions to every interview problem I'm given.

    If you gave me this answer, I'd put you lower on the list, because that's a loop and solving this with a loop is RBAR.

    That said, of the 10 or so DBA wannabe's who I've had the pleasure to interview, only one ever came up with a solution for FizzBuzz at all in the hour we gave them.

    oh btw, when we do a SQL test, we give you a PC with a copy of SQL 2008 R2 installed and a test database with a tally table populated up to 11,000 in it.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • mtassin (6/4/2012)


    If you gave me this answer, I'd put you lower on the list, because that's a loop and solving this with a loop is RBAR.

    That said, of the 10 or so DBA wannabe's who I've had the pleasure to interview, only one ever came up with a solution for FizzBuzz at all in the hour we gave them.

    oh btw, when we do a SQL test, we give you a PC with a copy of SQL 2008 R2 installed and a test database with a tally table populated up to 11,000 in it.

    I think you've just let me know that I don't want to work for you 😉

    As I said, I like to produce multiple solutions to any problem then narrow down the best one for our particular set-up. RBAR does win in some situations, as much as we SQL developers don't like to admit it, so when I produce a solution I always include at least one RBAR alternative. Normally, this is just used in the stats that I produce to show that it is most definitely not a good idea. But sometimes, it wins.

    For FizzBuzz, I'd produce the following two solutions: -

    Cadavre (5/24/2012)


    Fizzbuzz is your evil interview? Really? It's as old as dirt (as are the solutions) 😛

    WITH t1 AS (SELECT 1 N UNION ALL SELECT 1 N),

    t2 AS (SELECT 1 N FROM t1 x, t1 y),

    t3 AS (SELECT 1 N FROM t2 x, t2 y),

    tally AS (SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS number

    FROM t3 x, t3 y)

    SELECT t.number,

    CASE WHEN t.number%3 = 0 AND t.number%5 = 0

    THEN 'FizzBuzz'

    WHEN t.number%3 = 0

    THEN 'Fizz'

    WHEN t.number%5 = 0

    THEN 'Buzz'

    ELSE CONVERT(VARCHAR(3),t.number)

    END AS result

    FROM tally t

    WHERE t.number <= 100 AND t.number >= 1;

    DECLARE @number INT = 1;

    DECLARE @fizzBuzz TABLE (number INT, result CHAR(8));

    WHILE @number <= 100

    BEGIN

    INSERT INTO @fizzBuzz (number, result)

    SELECT @number, CASE WHEN @number%3 = 0 AND @number%5 = 0 THEN 'FizzBuzz'

    WHEN @number%3 = 0 THEN 'Fizz'

    WHEN @number%5 = 0 THEN 'Buzz'

    ELSE CONVERT(VARCHAR(3),@number) END;

    SET @number = @number + 1;

    END;

    SELECT number, result

    FROM @fizzBuzz;

    I'd like to think that I'd have demonstrated to a potential interviewer that I don't just assume that there is one solution to a problem. If I failed to get a job because I've produced more than one working solution, I'm pretty sure I didn't want the job anyway.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • Michael Valentine Jones (5/24/2012)


    Brevity and obscurity

    declare @ char(3)

    set @=0

    while @<100

    begin

    set @=@+1

    print

    case when @%15=0 then 'FizzBuzz'

    when @%3=0 then 'Fizz'

    when @%5=0 then 'Buzz'

    else @ end

    end

    I didn't realize that you didn't need any characters after the @ for a SQL variable. Thanks for that little tidbit (even though I probably would only use it to test a small script). 🙂



    The opinions expressed herein are strictly personal and do not necessarily reflect the views or policies of my employer.

  • I've tried the ol' FizzBuzz test on some folks. A lot of them can't even begin it because they have never worked with things like Modulo (%) before. If you want someone with those extra bit of math skills (even though they seem simple to many), it's an ok litmus strip. If not, then I'd pick a different test. Remember that the purpose of interviews isn't to see how many people you can reject... the purpose is to find someone who has enough skills to do at least an adequate job and who has the ability to learn over time.

    As a side bar, anyone who writes code as well formed as Cadavre did, even though it was a loop, has already caught my attention. I can train them how to avoid the loop. It's much more difficult to train someone to take pride in their code and to show sensible formatting even when they're under the gun.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • LightVader (6/5/2012)


    Michael Valentine Jones (5/24/2012)


    Brevity and obscurity

    declare @ char(3)

    set @=0

    while @<100

    begin

    set @=@+1

    print

    case when @%15=0 then 'FizzBuzz'

    when @%3=0 then 'Fizz'

    when @%5=0 then 'Buzz'

    else @ end

    end

    I didn't realize that you didn't need any characters after the @ for a SQL variable. Thanks for that little tidbit (even though I probably would only use it to test a small script). 🙂

    Doing this has been depreciated by Microsoft.

    Edit: Bit by the quote bug.

  • Lynn Pettis (6/5/2012)


    LightVader (6/5/2012)


    Michael Valentine Jones (5/24/2012)


    Brevity and obscurity

    declare @ char(3)

    set @=0

    while @<100

    begin

    set @=@+1

    print

    case when @%15=0 then 'FizzBuzz'

    when @%3=0 then 'Fizz'

    when @%5=0 then 'Buzz'

    else @ end

    end

    I didn't realize that you didn't need any characters after the @ for a SQL variable. Thanks for that little tidbit (even though I probably would only use it to test a small script). 🙂

    Doing this has been depreciated by Microsoft.

    Edit: Bit by the quote bug.

    Thanks Lynn. I'll keep that in mind. In general, I like to name my variables, so it wasn't something that I thought I would use often, if at all. I had just assumed that you needed to have at least one character after the @ and at some point, that assumption had been wrong.



    The opinions expressed herein are strictly personal and do not necessarily reflect the views or policies of my employer.

  • I'm sure this will come off sounding stupid, but I have never heard of Fizzbuzz. I see the solutions, but I don't understand what you're solving.

    Could someone elaborate for poor little uneducated me?

    Danke.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Brandie Tarvin (6/7/2012)


    I'm sure this will come off sounding stupid, but I have never heard of Fizzbuzz. I see the solutions, but I don't understand what you're solving.

    Could someone elaborate for poor little uneducated me?

    Danke.

    FizzBuzz was invented by IBM I believe to test your ability to develop.

    It's a made up problem where you have to return all the numbers from 1 to 100.

    Numbers divisible by 3, you return Fizz instead of the number

    Numbers divisible by 5, you return buzz instead of the number

    Numbers divisible by both, you return FizzBuzz instead of the number.

    It's more of a test of your ability to think than anything.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

  • Brandie Tarvin (6/7/2012)


    I'm sure this will come off sounding stupid, but I have never heard of Fizzbuzz. I see the solutions, but I don't understand what you're solving.

    Could someone elaborate for poor little uneducated me?

    Danke.

    Pfieuw. I thought I was the only one 😀

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • mtassin (6/7/2012)


    Brandie Tarvin (6/7/2012)


    I'm sure this will come off sounding stupid, but I have never heard of Fizzbuzz. I see the solutions, but I don't understand what you're solving.

    Could someone elaborate for poor little uneducated me?

    Danke.

    FizzBuzz was invented by IBM I believe to test your ability to develop.

    It's a made up problem where you have to return all the numbers from 1 to 100.

    Numbers divisible by 3, you return Fizz instead of the number

    Numbers divisible by 5, you return buzz instead of the number

    Numbers divisible by both, you return FizzBuzz instead of the number.

    It's more of a test of your ability to think than anything.

    Thank you. That helps me understand why the posted code solutions are doing what they are doing.

    "And knowing is half the battle!"

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 15 posts - 16 through 30 (of 63 total)

You must be logged in to reply to this topic. Login to reply