SQL Interview: Tips From Recruiter and Sample Questions with Solutions

sql jobs entry level, create sql job to run stored procedure, sql job schedule, sql jobs salary, sql job example, sql server agent jobs, sql job description, sql job syntax, sql interview, sql job, sql interview questions for developers, sql interview questions pdf, sql interview questions for data analyst, sql interview queries

Applying for an SQL-related position? You’ll likely have to pass an interview process. But you’ll be much better prepared for the interview if you know what to expect. This article sheds some light on the recruiter’s perspective to better prepare you for your interview.

 

SQL Knowledge and Skills

There are different SQL skills that an interview can test. These include:

  1. Skills related to any specific SQL database engine (like PostgreSQL, MySQL, or Oracle).
  2. Skills associated with SQL clients or SQL tools (like Tableau, Domo, TeamSQL, Vertabelo and pgAdmin, among others).
  3. Skills or expertise related to SQL’s theoretical concepts.

You need to be ready to cover all of these three areas. During the interview, you should try to demonstrate all the relevant SQL knowledge you have with thoughtful responses.

SQL Database Engine Skills

For this category, you should know a few things about each of the most important database engines on the market.

If the recruiter mentions an engine you’ve worked with, then go ahead and share your thoughts. However, if you haven’t worked with that particular engine, you can instead give a short answer from the following table:

Database name Main characteristics Type of product and cost
Oracle Very popular and solid database software. Oriented to transactional or warehouse applications. Available on several operating systems. Uses standard SQL. product with cost
SQL Server Very popular and solid database. Oriented to transactional or warehouse applications. Available only on Windows. Uses standard SQL. product with cost
PostgreSQL Very solid database. Popular in the free software community. Oriented to transactional or warehouse applications. Available on Linux and Windows. Uses standard SQL. free product
MySQL Very popular database. Oriented to web applications. Available on Linux and Windows. Uses standard SQL. free product (owned by Oracle)
Amazon Redshift PostgreSQL database offered as a cloud service. oriented to warehouse applications. Uses standard SQL. service with cost
Amazon Azure SQL server database offered as a cloud service. Oriented to transactional and web applications. service with cost
MongoDB Non-SQL database (stores unstructured data like xml, pdf, html). Uses a language similar to SQL. free product

Please note there’s a different rule for candidates with a higher level of experience.

If your recruiter is looking for a candidate with 5 years of experience with one specific database engine—such as Oracle—and you’ve never used it, it’s best that you be honest and tell the truth upfront.

As a recruiter, I like honest candidates; in some exceptional cases, I’ve actually recruited candidates who were strong in other areas, even if they had no experience with one specific database engine.

SQL Clients and Tools

In some cases, SQL job descriptions list specific SQL clients or SQL tools. These days, there are several online platforms/tools for creating reports, graphs, and cards to show business metrics (Domo, Periscope Data, Tableau, etc.). All of these tools are fed with SQL queries.

These tools are generally easy to learn—the hard part is knowing how to write the right SQL queries.

If your recruiter starts discussing a specific tool, take a deep breath. You should feel comfortable just talking about SQL.

Believe me—your interviewer will still see great value in a candidate who has lots of SQL experience, even if that candidate has no experience with a specific tool.

SQL in Action

Some interviewers cut straight to the chase and ask you to solve a problem by writing an SQL query. They’ll usually give you a data model and a specific question to answer. If you have doubts about the data model, please take your time to review the data model before asking your interviewer any questions. In some cases, your comprehension of the data model itself is part of the interview.

If you still have doubts or questions after reviewing the data model, you should formulate a thoughtful question that demonstrates what you understand as well as what you need help with.

Below are some sample problems with the solutions included.

Sample Questions with Solutions

Sample Query: Entry Level

Data Model: Cities (city_id, city_name, state_id, population) Cities (city_id, city_name, state_id, population)

Query to solve: Retrieve the names of the cities with more than 100000 people. The result must be ordered with the least populated cities near the end.

Solution:

SELECT city_name
FROM cities
WHERE population > 100000
ORDER BY population DESC

Sample Query: Joins and Filters

Data Model: Cities (city_id, city_name, state_id, population, is_capital)
States(state_id, state_name, foundation_date)

Query to solve: Retrieve the name and state name of each capital city of a state starting with the letter ‘F’.

Solution:

SELECT city_name, state_name
FROM cities, states
WHERE cities.state_id = states.state_id
AND cities.is_capital = true

Sample Query: Aggregates

Data Model: Cities (city_id, city_name, state_id, population)

Query to solve: Retrieve the name and total population of each state.

Solution:

SELECT state_name, SUM(population)
FROM cities, states
WHERE cities.state_id = states.state_id
GROUP BY cities.state_id

Sample Query: Subqueries

Data Model: Cities (city_id, city_name, state_id, population, is_capital, distance_to_capital)

Query to solve: For each state, retrieve the name of the city that’s farthest from its capital.

Solution:

SELECT city_name
FROM cities C1
WHERE distance_to_capital = ( 	SELECT MAX(distance_to_capital)
FROM cities C2 
WHERE C1..state_id = C2.state_id
       )
AND cities.is_capital = false

Conclusion

Job interviews seem harder than they really are. People tend to get nervous as the deadline draws near, but the best thing you can do is remain calm and practice writing queries before the interview. Here are some additional things to keep in mind:

  • Be confident in yourself.
  • Don’t lie about your experience.
  • Lead the conversation when possible.
  • Put all of your knowledge on the table.

Good luck! And if you’re interested in learning more advanced SQL concepts, go ahead and check out Vertabelo Academy’s Standard SQL Functions course.

Ignacio is a database consultant from Buenos Aires, Argentina. He’s worked for 15 years as a database consultant for IT companies like Informix and IBM. These days, he teaches databases at Sarmiento University and works as a PostgreSQL independent SQL consultant. A proud father of four kids with 54 years in his backpack, Ignacio plays soccer every Saturday afternoon, enjoying every match as if it’s his last one.

GET ACCESS TO EXPERT SQL CONTENT!