TSQL "where - 101"

  • Ed Wagner (11/12/2014)


    vivekjamshedpur (11/12/2014)


    Both choice 3 and 4 is correct.Because author does not say duplicate names are ok.:crazy:

    No, they aren't. He even bolded the word "all" in the question. Even without bolding it, it would have still meant the same thing.

    Or put it another way, there are 4 records that are either grant or steve, therefore 6 that aren't.

    Irrespective of name, returning all the employees who aren't called grant or steve, should return 6 rows, using distinct doesn't.

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • Stuart Davies (11/12/2014)


    It was sparked by new dev here, who couldn't see the difference between any of the four possible answers :w00t:

    As the question and answer showed mixed cases, case insensitivity is implied, again something missed by our now ex dev.

    Wow, that's rough. Your company must believe it's easier to hire a new dev than train an existing dev. :blink:

  • Dave62 (11/12/2014)


    Stuart Davies (11/12/2014)


    It was sparked by new dev here, who couldn't see the difference between any of the four possible answers :w00t:

    As the question and answer showed mixed cases, case insensitivity is implied, again something missed by our now ex dev.

    Wow, that's rough. Your company must believe it's easier to hire a new dev than train an existing dev. :blink:

    This was just part of a much bigger picture regarding them and their becoming an ex employee. But dirty washing and all that . . . . .

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • Thanks for the great question!



    Everything is awesome!

  • From my standpoint :

    It should not be a programmer's responsibility (alas it sometimes is) to figure out what some quirky piece of code might be doing,

    but to express his ideas in a natural way, so there is only one candiddate worth considering - guess which.

  • h.tobisch (11/12/2014)


    From my standpoint :

    It should not be a programmer's responsibility (alas it sometimes is) to figure out what some quirky piece of code might be doing,

    but to express his ideas in a natural way, so there is only one candiddate worth considering - guess which.

    If the programmer doesn't figure out what the code is doing, then who does? Who wrote the code in the first place?

  • Impossible. There are multiple correct answers.

    JK

    Ducks and runs - snigger.:-D:-D:-D:hehe:

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Ed Wagner (11/12/2014)


    h.tobisch (11/12/2014)


    From my standpoint :

    It should not be a programmer's responsibility (alas it sometimes is) to figure out what some quirky piece of code might be doing,

    but to express his ideas in a natural way, so there is only one candiddate worth considering - guess which.

    If the programmer doesn't figure out what the code is doing, then who does? Who wrote the code in the first place?

    Agreed. It's often my job to figure out what some quirky piece of code is doing. Of course, if I'm really doing my job, I'll document it so the next person doesn't have to figure it out.

  • marcia.j.wilson (11/12/2014)


    Ed Wagner (11/12/2014)


    h.tobisch (11/12/2014)


    From my standpoint :

    It should not be a programmer's responsibility (alas it sometimes is) to figure out what some quirky piece of code might be doing,

    but to express his ideas in a natural way, so there is only one candiddate worth considering - guess which.

    If the programmer doesn't figure out what the code is doing, then who does? Who wrote the code in the first place?

    Agreed. It's often my job to figure out what some quirky piece of code is doing. Of course, if I'm really doing my job, I'll document it so the next person doesn't have to figure it out.

    I couldn't agree more about the comments. Before we learned that lesson, how many times have we looked at our own code from 4 years ago and wondered what we were trying to accomplish? It was more than a few times for me, but I don't have to deal with that now that the lesson sunk in.

    In general, how many times does a DBA have to figure out what's going on? I guess it depends on how often we're asked to help others or work with code - either our own or code from others.

  • Nice, easy question, Stuart. I also noticed the case difference and thought I would mention it in my reply if nobody else did, but of course I wasn't the first to notice that.

    It's unfortunate that some developers can't see the difference between those expressions. A firm grasp of basic Boolean algebra should be a prerequisite for any developer, and understanding what DISTINCT does in a SQL statement should be a prerequisite for any database developer.

  • SQLRNNR (11/12/2014)


    Impossible. There are multiple correct answers.

    JK

    Ducks and runs - snigger.:-D:-D:-D:hehe:

    Like... what?? If you don't present your case and argue why you think so, then why bother writing a comment here?

  • Yes, the question and possible answers are not aligned. All queries return employee names, not employee (entities). Therefore no answer can be correct.

  • hjp (11/12/2014)


    SQLRNNR (11/12/2014)


    Impossible. There are multiple correct answers.

    JK

    Ducks and runs - snigger.:-D:-D:-D:hehe:

    Like... what?? If you don't present your case and argue why you think so, then why bother writing a comment here?

    There are always multiple correct answers. Some may perform better than others and some may be more maintainable than others, but there are always multiple ways to get to the right answer. The trick lies in finding the best one.

  • hjp (11/12/2014)


    SQLRNNR (11/12/2014)


    Impossible. There are multiple correct answers.

    JK

    Ducks and runs - snigger.:-D:-D:-D:hehe:

    Like... what?? If you don't present your case and argue why you think so, then why bother writing a comment here?

    Hint in the JK and the smileys.

    It was a Joke.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • SQLRNNR (11/12/2014)


    hjp (11/12/2014)


    SQLRNNR (11/12/2014)


    Impossible. There are multiple correct answers.

    JK

    Ducks and runs - snigger.:-D:-D:-D:hehe:

    Like... what?? If you don't present your case and argue why you think so, then why bother writing a comment here?

    Hint in the JK and the smileys.

    It was a Joke.

    Phew - that's a relief - I didn't know if I should respond to it or not and didn't know how to put my argument! 😉

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

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

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