My favorite tech interview question.

From time to time I’ve been called on to conduct technical interviews of people seeking a new job.  I’ve always enjoyed this task.  It’s fun talking with people and geeking out about SQL.  That’s the good news.  The bad news is, not EVERYONE is completely honest in the way they evaluate their own SQL skills.  In those rare times when I do a tech interview with someone that is … let’s say a little ‘generous’ in the way they rate their own SQL skills, it’s my job to determine that and gauge their actual skill level.

There are (of course) a LOT of ways to do this.  There are tons of blog posts with sample interview questions.  This post is about my favorite question to ask job seekers that claim to be expert at SQL development.

“What is the purpose of the HAVING clause in a SQL query?”


Let’s think about this for a minute.  I write a LOT of queries.  I bet some of you do too.  How often do you use HAVING?  Me?  rarely.  Apparently, I’m not alone.

I’d guess this question trips up 85% or more of the people I ask.  It’s fair to say that a tech interview for a job you want is high pressure.  I get it.  I myself did a tech interview as the candidate recently and struggled to answer the question ‘What is a primary key’.

The answer, for those of you playing along at home, is the HAVING clause filters the groups (or aggregates) defined in our query.  Bonus points if you know that a HAVING without a GROUP BY acts like a WHERE clause.  EXTRA bonus points if you mention this blog post when I ask you this question in a technical interview someday.  🙂

p.s.  I was able to articulate the purpose and use of a primary key but it wasn’t my finest moment.  It’s scary as hell to have to answer questions like this when your dream job is on the line, even when you know this stuff cold.  If you’re on the hunt for your next gig I hope this post helps.  Good Luck!


Leave a Reply

Your email address will not be published. Required fields are marked *