After a while, we are hiring again, and I'm reviewing tests for programmers; some of them are a bit out of date. What are some of the FizzBuzz-type questions for web developers and SQL? That is, not too trivial, but still solvable in five to ten minutes with pen and paper and without Google?

I typically eliminate about two thirds or more of the candidates based on CV, and then all but a few really good candidates in a one-hour interview (which can be over the phone). At this point the candidate is writing a personality test and has a chance to write a bit of FizzBuzz-like code. So, I'm not trying to eliminate a bunch of candidates, but I am trying to validate my initial assessment that candidate is hireable and able to code.

  • 2
    What skills do you look for in a web developer?
    – Oded
    Commented Dec 5, 2011 at 18:25
  • I guess I'm looking for the understanding of HTML/CSS/JSON/HTTP; as Rachel mentioned, FizzBuzz is fine for testing Javascript/PHP/etc.
    – Domchi
    Commented Dec 5, 2011 at 21:13

4 Answers 4


I see FizzBuzz as a test to see if people actually know what they claim to know on their Resume. I wouldn't use it as anything other than a question to weed out candidates that don't know what they're talking about.

A suitable SQL replacement would be to just ask the candidate to write a SQL statement such as selecting the Name fields of two joined table that begin with A. It's simple and demonstrates that the candidate actually does have some knowledge of SQL.

SELECT Table1.Name, Table2.Name
FROM Table1 
INNER JOIN Table2 ON Table1.Id = Table2.Id
WHERE Table1.Name LIKE 'A%' OR Table2.Name LIKE 'A%'

For a web developer I would just ask them FizzBuzz. Just because you're programming for the web doesn't mean you should lack the ability to do basic programming logic

If you're looking for actual interview questions, there are plenty of good ones online that you can find with a quick search. I found more than I care to list by taking 10 seconds with Google.

  • 2
    Joins are a good way to separate the rookies from the more advanced SQL programmers, since in SQL programming usually requires a different paradigm for thinking than server-side programming which is usually imperative. Joins and subqueries used to stump me until I started thinking of SQL statements in terms of sets.
    – Chris C
    Commented Dec 5, 2011 at 20:43
  • @CCRicers I agree. And if you're interviewing for an advanced SQL developer, I'd actually also add a GROUP requirement to that, since I worked with SQL quite a bit before I fully understood what groups meant and how they work
    – Rachel
    Commented Dec 5, 2011 at 21:04
  • Consider requiring a self-join: "CREATE TABLE EMPLOYEE(ID NUMBER, NAME TEXT, MANAGER_ID NUMBER)" then "How can I list employees and their managers?" Commented Dec 5, 2011 at 21:12
  • Depending on what type of database/SQL position you're hiring for (and developer background/your environment), you can ask for an actual 'FizzBuzz' answer. Commented Dec 5, 2011 at 22:30
  • And it has the additional advantage that it's a poor spec, so it tests whether the candidate clarifies requirements before writing code. Commented Dec 6, 2011 at 13:24

Here is an answer I gave to a very similar (possibly duplicate) question that was closed on this site.

Extremely Easy Level: Given an employees table with the columns EmpID, FirstName, Lastname, HireDate, and TerminationDate: Write a query to return all employees still working for the company with last names starting with "Smith" sorted by last name then first name.

Easy Level Given the Employee table above, plus a new table "AnnualReviews" with the columns EmpID, and ReviewDate: Write a query to return all employees who have never had a review sorted by HireDate.

Medium Level
Given the employee table above, write a query to calculate the difference (in days) between the most and least tenured employee still working for the company?

Hard Level Given the employee table above, write a query to calculate the longest period (in days) that the company has gone without a hiring or firing anyone.

Harder Level
Again using the same tables, write a query that returns each employee and for each row/employee include the greatest number of employees that worked for the company at any time during their tenure and the first date that maximum was reached. Extra points for not using cursors.

  • 1
    Interesting question. However, the "Hard"/"Harder" level seems really hard to me. Even with decent SQL experience, I believe it's probably too hard to solve in an interview situation. Maybe if you leave the candidate alone for half an hour or so.
    – sleske
    Commented Dec 6, 2011 at 13:37
  • I could tell the "harder" question was hard when I realised I don't even really know what a cursor is... and I used MySQL every day! :-/ Commented Dec 6, 2011 at 16:15
  • @Johnfx Can please see these answers for ur problems I've interview day after tomorrow, docs.google.com/document/d/… Commented Apr 20, 2013 at 19:45
  • Why do you need me to look at it. You can test it yourself and see if you get the right answer.
    – JohnFx
    Commented Apr 21, 2013 at 3:06

How about fizzbuzz itself? Here's an Oracle version:

select case when mod(level,35) = 0 then 'fizzbuzz'
            when mod(level,7) = 0 then 'buzz'
            when mod(level,5) = 0 then 'fizz'
            else to_char(level) end fizzbuzz
from dual connect by level <= 100
  • 1
    +1 for awesomeness, but I think virtual numbers tables don't come up often enough to be in everyone's SQL tool box. You'd have to spot them that Commented Dec 6, 2011 at 16:20

I find that people tend to have a lot of trouble working with time for some reason, so that may be a good place to put a small test.

Something like this:

Part 1: Create a function that will calculate the Nth or last weekday in a given month - ie; the first, third, last Tuesday in next month.

Part 2 (if desired): Design table(s) to hold temporal expressions for recurring schedules. The schedules could be any of "the Nth weekday of one or more months" or "the Nth day of one or more months" or "every N days from date".

Example, the 15 of every month, the last Wednesday of every March, the last day of every month, every 17 days from December 2nd, 2008, etc.

  • 2
    -1: Working with time and getting it right IS indeed hard. Guess why libraries like JodaTime exist and are not just some trivial piece of software. Commented Dec 5, 2011 at 20:49
  • @sebastiangeiger I agree. I work with SQL almost daily and although I can use SQL's date functions efficiently, I wouldn't be able to do something like this quickly or easily without the aid of Google. In fact, I needed to do this a few months ago and after a few minutes of trying to figure it out in SQL, I just Googled it and got some scripts which I use with some modifications to suit my needs.
    – Rachel
    Commented Dec 5, 2011 at 21:01
  • I'm not looking for trouble areas; I'm looking for something any average developer is working with on daily basis and can recall without any problem and in an unfamiliar environment (no computer available). While your example is not that hard, it's more of a problem I'd give to someone coding in front of me to see how he's thinking.
    – Domchi
    Commented Dec 5, 2011 at 21:08
  • 1
    @Eli I think FizzBuzz is expected to be solved/coded accordingly. Commented Dec 5, 2011 at 23:04
  • 1
    I don't think that Part 2 is a good question. In fact this topic has an odd solution that does not occur almost in any other database design problem in business. not knowing the answer is not an indication of poor SQL knowledge.
    – NoChance
    Commented Dec 5, 2011 at 23:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.