Interview question to test beginner SQL competency?

  • Hello,

    I need to help my boss come up with a simple-ish SQL quiz. Myself and another analyst from our department are leaving and were the only two who know how to write queries. I am beginner level at best and I don't feel qualified to test someones capabilities. I received a job offer and when they found out i could write sql they gave me this quiz in access. (We use MSFT SQL server management server)

    SELECT userid, AVG(orderid), FROM tbl.companytable HAVING (orderid) > 0;

    "Whats wrong with this query?"

    Me - you need to partition orderid by userid otherwise you will get multiple user IDs and have the same average of all order IDs

    Them - right, so group by

    I want to do something like this, but cant really think of the best parameters in our DB to use, any advice on a simple query question to ask is greatly appreciated.

    My main goal is to not filter out a potentially good candidate just because i asked a poor question.

    Thanks in advance.

  • Sounds like a prelude to spam...  why would anyone in their right mind try to take an average on such an identifier column?  Really bad question and, since you say they say you got the answer right, I doubt their ability to form a decent question, as well.

    --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

  • For introductory stuff, I always asked these questions. Obviously, a few would need to be updated, it being 2022 & all. However, I'd still say these were pretty basic, core stuff, to get a quick understanding of where someone's knowlege level is.

     

    ----------------------------------------------------The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood... Theodore RooseveltThe Scary DBAAuthor of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd EditionProduct Evangelist for Red Gate Software

  • This was removed by the editor as SPAM

Viewing 4 posts - 1 through 4 (of 4 total)

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