Challenging SQL interview questions

  • I received these 3 questions from my friend. Can anyone help me answer these?

    1. How would you check that there are an odd number of lines in a given file? What if there was a folder of many files to check?

    2. In a text, tabular file, how would you check that the second column contains only even numbers?

    3. Given the following ERD: http://www.fda.gov/cder/drugsatfda/datafiles/erd.png, write a select statement that would retrieve the count of "App Doc" records that had an "Action Date" greater than yesterday and a "CHEMICAL_TYPE" of "Bad".

    Thanks!

  • Why would our helping you to get a job that you are apparently unqualified for be a good thing?

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • RBarryYoung (4/4/2009)


    Why would our helping you to get a job that you are apparently unqualified for be a good thing?

    Why would your being rude to someone you have never met be a good thing?

    😛

  • Paul White (4/5/2009)


    RBarryYoung (4/4/2009)


    Why would our helping you to get a job that you are apparently unqualified for be a good thing?

    Why would your being rude to someone you have never met be a good thing?

    😛

    What in his reply is rude?

    There's an unwritten rule here that we do not answer interview questions and we do not do homework. At best, we'll offer hints. How would you feel if you were working with someone who had passed an interview via forum help and didn't know anything about the work they were doing?

    ssbp2we: The first 2, import them into SQL and check. As for the third one, that's not a difficult query. I would suggest that your friend brush up on his SQL skills before the next interview.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • If the rule is unwritten then how was the OP supposed to be aware of it?

    Why not just state the unwritten rule to the OP?

    Why say the OP is unqualified for some position we know nothing about? It's insensitive at best, and rude to my mind. If you can't say something nice...!

    I have no idea how people who have clearly been around on this forum for a while, can assume so many things from so little information. The OP's English may not be fantastic, or (s)he may not have explained the question very well....or well you name it.

    A good test in these situations is to consider whether one would say what one posts to the OP's face in real life. Also try to remember what it was like when you first started out.

    My original post was somewhat tongue-in-cheek, but now that you ask me, you have a serious answer.

    Cheers,

  • Paul White (4/5/2009)


    If the rule is unwritten then how was the OP supposed to be aware of it?

    I never said they had to be aware of it. That comment was for you, not the OP. We just don't answer interview questions here.

    I have no idea how people who have clearly been around on this forum for a while, can assume so many things from so little information.

    Possibly because this type of thing comes up again and again and again and again.

    A good test in these situations is to consider whether one would say what one posts to the OP's face in real life.

    In this case, I would say that and I have in the past. Not to beat them down, but to point out that memorising answers for interviews or lying in interviews is ultimately a destructive strategy

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • GilaMonster (4/5/2009)


    I never said they had to be aware of it. That comment was for you, not the OP. We just don't answer interview questions here.

    Well you are free to answer or not answer as you please of course. As am I, naturally 🙂

    GilaMonster (4/5/2009)


    Possibly because this type of thing comes up again and again and again and again.

    Sounds like someone needs a holiday!

    GilaMonster (4/5/2009)


    In this case, I would say that and I have in the past. Not to beat them down, but to point out that memorising answers for interviews or lying in interviews is ultimately a destructive strategy

    In person, I imagine it would come across better. The subtle cues that show that you are trying to be helpful, or have their best interests at heart, don't always come across so well in print.

  • Paul White (4/5/2009)


    GilaMonster (4/5/2009)


    I never said they had to be aware of it. That comment was for you, not the OP. We just don't answer interview questions here.

    Well you are free to answer or not answer as you please of course. As am I, naturally 🙂

    GilaMonster (4/5/2009)


    Possibly because this type of thing comes up again and again and again and again.

    Sounds like someone needs a holiday!

    GilaMonster (4/5/2009)


    In this case, I would say that and I have in the past. Not to beat them down, but to point out that memorising answers for interviews or lying in interviews is ultimately a destructive strategy

    In person, I imagine it would come across better. The subtle cues that show that you are trying to be helpful, or have their best interests at heart, don't always come across so well in print.

    First, you are correct, we are free to answer or not. In this case, someone chose to answer in what you thought was rude manner. I don't agree, and neither did Gail.

    We don't answer interview questions, and we reserve the right to inform posters of that fact. We will, however, work with them in learning aspects of SQL Server. The caveat to that assistance is that the OP needs to make an effort to learn, not just memorize answers that may help them get a job working with SQL Server.

    Also, as you are fairly new to SSC, you obviously haven't seen the numerous posts from various people asking for the same type of answers. Those of us who have been here a while have, and as highly skilled professionals, we don't want to see unqualified people getting positions for which they obviously don't qualify to hold. We'd prefer that these individuals learn the skills they need and seek out positions that would help them in this endeavour. Again, we would be more than willing to help them increase their knowledge through actual practice. It could be trying to answer others questions on this site, or helping them work through problems of their own devising. Anything that helps them actually increase their knowledge, not just memorizing answers.

    Nothing, in any of the posts on this thread appeared to beat down or discourage anyone. Everything stated was stated in a professional and polite manner.

  • We do not, as a rule, like to answer interview or homework, as stated.

    That being said, I can see where you thought the first response was a little short, and possibly rude.

    I would like to see a standard answer for this, and perhaps I can create one. The idea is that people should make an attempt to do work before posting a question, or at least given it some thought.

  • Hi

    Maybe the part with "apparently unqualified" was a little rude. Sorry for that Barry! But he is also right with it. Maybe I would write it in another way (e.g. as Gail did, no homework no interview questions). The topic "interview questions" seems also a little bit unfortunately.

    I also don't like posts without any effort. I always try to help since I see that the OP also brings his part (don't know if this was correct English - don't think so :hehe:). Three questions where one is a picture without any sample data or something else seems to be a little less for me.

    But

    The poster is always free to explain a little more about the "why". If (s)he gives an explanation which makes sense everybody will help!

    So @ssbp2we

    Could you please explain why you need this information?

  • Paul White (4/5/2009)


    RBarryYoung (4/4/2009)


    Why would our helping you to get a job that you are apparently unqualified for be a good thing?

    Why would your being rude to someone you have never met be a good thing?

    😛

    Well, I don't think that I was being rude. I do think that the OP presented themselves as doing something unethical and asked us to participate in it. I asked the above question because I wanted the OP to understand that they did appear to be engaging in an unethical activity and to give them the chance to correct that impression if it was not true.

    As for the "apparently unqualified" part, when someone surreptitiously solicits assistance on questions it gives a very strong appearance that they are unable to answer those questions. These questions were interview questions which would therefore be used to determine someone's qualifications for a job, I think it logically sound to conclude that they were giving the appearance of being unqualified for that job.

    And I choose to include "apparently unqualified" because it was what made the point that what they were asking us to do appeared to be unethical. And one thing that I will not do is to participate in unethical activities or condone them with my silence, even if some may incorrectly think that to be rude. Courtesy does not override ethics. Where possible they should always go together, however in the event that they are in conflict, ethics always takes precedence.

    If you see some error in this, please let me know what it is, until then I plan to continue with what I believe to be the ethically proper response to questions like this, which is to point out that it appears to be unethical and to give them the opportunity to correct that impression, which is what I did. If in Steve's judgment there is a better or more proper response, then I am happy to accede to that.

    (edit: correcting typos)

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Paul White (4/5/2009)


    If the rule is unwritten then how was the OP supposed to be aware of it?

    Because it is not just a matter of the unwritten rules of this site, it is more importantly a matter of professional ethics.

    And I am pretty sure that the OP understands that cheating is wrong. If not, then they need to understand that (and a whole lot more) before they are ready to be trusted with the responsibilities of a professional. If that seems harsh, please try to remember that a very large part of what caused the current global financial collapse was cheating and other unethical behavior by a lot of professionals who should have known better.

    And yes they are connected. Looking the other way on professionals who want to cheat on their applications and interviews today, is what leads to a culture of professionals tomorrow who have no regard for standards, practices or ethics because "it doesn't really matter" or "everyone does it" or "nobody really cares".

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Paul White (4/5/2009)


    A good test in these situations is to consider whether one would say what one posts to the OP's face in real life.

    I have been on the internet for 30 years, I am aware of this rule and I do try to practice it all the time. You do not know me, but those who do will tell you that I would have no hesitation asking a question like that face to face, and in public. I have no truck with the idea that we should look the other way on immoral behavior because it might seem rude or discourteous to say something about it.

    I am also a firm believer in giving people the chance to correct bad or mistaken impressions. If you never say anything and just walk away, they never get the opportunity to explain themselves. It may be socially uncomfortable, but it is better, and right to let them know about the bad impression and to give them that chance to correct it..

    Also try to remember what it was like when you first started out.

    I do, every day. It is the whole reason that I am here in the first place. And I have taken that stand (that we should remember what that is like) many times in this forum and will continue to do so. I think that my record speaks for itself on that issue.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Paul White (4/5/2009)


    A good test in these situations is to consider whether one would say what one posts to the OP's face in real life.

    I also feel compelled to point out that that rule was in fact derived from two even better rules that preceded the internet by many decades:

    1) Never say or do anything that you wouldn't want your mother to know about. And,

    2) Never say or do anything professionally that you wouldn't want your current or a future employer to know about.

    I think that #2 is even more important today, and on the internet, than ever. If the OP can show us that they were in fact complying with this rule, then I would be more than happy to help them.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Lynn, Gail, thanks for the support while I was unable to answer.

    And Steve, whatever you decide is fine by me.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 15 posts - 1 through 15 (of 51 total)

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