There are more and more data related positions like Data Engineer or Data Analyst. And of course, SQL is a very important part of this kind of position. Lack of SQL experience is definitely the blocker to get offers from those big companies.
I’m a data engineer and I sometimes do SQL, python for candidates. Though every company has different requirements for the expertise of SQL skills, the tips I share should be applicable for all the positions that require SQL interviews. These are all the tips that you might already know but sometimes forgot during the interview because of being nervous.
Feel free to comment and let me know your feedback!
1.Make sure you understand the problem statement
importance level: ★★★★★
This tip applied to all the interview questions. Especially for leetcoder, you may find the interview question is similar to one of hundreds of leetcode questions you have cracked.
For SQL Interview, one useful way to show you really understand the problem statement is to write down the desired output column for the question.
Bonus point:
As a data engineer, you may work with people that don’t really have data knowledge at all. And sometimes, users may also ask the wrong question.
If you find anything not clear from the question, the interviewer will be very impressed. Since everyone wants to work with detail-oriented people.
2.Write down pseudo-code or implementation steps
importance level: ★★★★
Just as other coding interviews, writing pseudo code can not only help you clean your mind but also help the interviewer understand how you are going to solve the question
When you finished the pseudo-code, you can even ask the interviewer if this solution really works.
Bonus point:
After you write down all the SQL code, you can even go back to the pseudo-code you write and add some corner cases you can think about.
3.Always start from the small query
importance level: ★★★★
I noticed that many candidates would try to write some big and complicated queries, then run the query at the end, expecting the query to be bug-free. It is definitely very impressive if you are able to write a query like this. But most of the time, you will run into errors when running a complicated query, and seeing errors make you nervous.
So, starting from the small query, and following the implementation steps you write, it can make debugging a lot easier.
Bonus point:
Take advantage of the CTE concept, so you can easily combine those small queries and make the query much more readable.
4.Think out loud
importance level: ★★★
I only gave this tip three stars, because it is not irreplaceable. As an interviewer, I know it’s not always easy to write code and explain at the same time. Not being able to do this doesn’t always make you a bad coder. In fact, many great coders are not good at this. However, it’s still very important to communicate and explain your approach to the interviewer. In this case, you can use other strategies. For example,
a. Write down pseudo-code or implementation steps before writing queries
b. Write the query first and explain all the logic after at the end. Of course, let the interviewer know it in advance, so they know what to expect.
5.Use the SQL language you are good at!
importance level: ★★★★
In general, the interviewer doesn’t care if you write MySQL, PostgreSQL, etc, only the logic matters. So, if your coderpad is using the one you are not familiar with, feel free to ask to change to the one you are good at!
If you are not allowed to change SQL language in the interview, make sure to let your interviewer know what kind of SQL function you are going to use in your preferred SQL language. Keep in mind, no one can be an expert in all languages and the interviewers know that.
Other tips:
If it is a Facebook phone interview, don’t worry about thinking out loud or pseudo-code, just write the queries as many as you can!
Thank you for reading the post. If you find this post useful, please upvote! I’ll prepare a second post for how to crack sql question by using resource in leetcode.