How to Learn SQL
One of the most requested skills as a data analyst is SQL. According to datanerd.tech (an app built by Luke Barousse which collects data from job postings daily from Google’s search results focusing on data science roles), about 54.5% of job postings ask for or require SQL as a skill. While there’s a lot of SQL languages (e.g. MySQL, PostgreSQL) there’s still a basis and fundamental knowledge you need to do. The differences between these languages are mostly on syntax and some may have functions that others don’t. If you learn one SQL language you can learn another, it’s just a matter of understanding the differences and nuances of each. But the underlying principles are the same (you can also use this as an answer if an interviewer/recruiter asks you if you know a SQL language if you don’t). Understanding these fundamentals come in handy during interviews when answering SQL questions.
SQL is vital for data analysts; roughly over half of job postings require it.
Hands-on practice and continuous learning are keys to SQL proficiency.
Follow my journey and recommendations to enhance your SQL skills and work towards being job-ready.
My Journey to Learning SQL
My first formal introduction was through the Google Data Analytics course, it gave me a good starting point but I still felt a bit lost. After that I decided to try out a more in-depth course from Udemy, The Complete SQL Bootcamp: Go from Zero to Hero. Which had a lot of opportunities to practice my skills with code along sessions. While it gave me the foundation to understanding SQL, I wanted to practice with more realistic scenarios. So, I decided to try searching for practice problems online. I started with the easy questions and moved onto the more intermediate and advanced.
After a while working on these problems felt repetitive. So I moved onto personal projects, specifically with my weightlifting project where I built my own database and analyzed my weightlifting data (note: I am updating this project with a more in-depth analysis so stay tuned for that). I got more comfortable with aggregate functions and CASE WHEN statements.
After this I felt more prepared for interviews and I became confident in my SQL skills. Below I’ll be going into the roadmap I used to learn SQL and suggestions.
Using SQL on the job is the most effective way to improve. After about 5 months in my current role, I’ve found that regular, hands-on experience with real, often messy data, offers a stark contrast to the sanitized datasets in many courses. For insights into using SQL in real-world scenarios, see my blog post, The Reality of Using SQL Day-to-Day as a Data Analyst.
But if you’re searching for your first data analyst role you don’t have this type of practice. What can you do instead? There’s a general framework I’d recommend. Think of it as different levels, once you’ve gotten good at one then move onto the next. Obviously everyone is different and some may want to jump to level 3 but this is for people who don’t know where to start.
Tutorials / Courses
The starting point could be tutorials on YouTube or formal courses. They guide you through the subject matter and walk through examples. These offer a structured learning environment similar to a classroom. For choosing the right SQL course consider these factors to find the right course for you:
Learning Objectives: Ensure the course aligns with whether you're aiming for basics or advanced concepts.
Teaching Style: Preview lessons to match your preference for theoretical insights or practical exercises.
Course Structure: Look for a balance of lectures, hands-on practice, and projects.
Budget: Courses range from free to premium; select one that offers good value within your budget.’
Reputation and Reviews: Consider past student experiences and the course provider’s credibility.
If you’re not sure where to start, I’d recommend checking out courses on platforms like Maven Analytics, Udemy (though there’s a lot of these) or a Youtube Tutorial like this one from Alex the Analyst: SQL Basics Tutorial For Beginners | Installing SQL Server Management Studio and Create Tables | 1/4 (this is one of four videos, check out the full playlist on Alex’s channel).
What’s next? It’s practice problems. This is a perfect blend of tutorials and projects. These problems help bridge the gap between guided learning and independent project work, offering solutions for self-assessment. Though, in the real world there are multiple ways to write a query to get the data you want. Look for problems that question you on the fundamentals like JOINs, aggregate functions, and CTEs/subqueries. The key is to understand the logic behind your answers, if you can explain your query to someone else that’s a good benchmark.
Here’s a few sites you can go to for this stage:
DataLemur - SQL, interview questions asked by top tech companies
W3Schools SQL Practice Problems - list of exercises to practice SQL
stratascratch - 1,000+ real interview questions from favorite companies, SQL and Python
hackerrank - gamify practicing coding skills (Python, SQL)
leetcode - with over 2,000 questions to practice coding skills
Once you’ve done a few practice problems. You don’t need to be a master to move onto this stage. Now, it’s time to apply your knowledge. For projects I also suggest approaching this in three stages or levels. It will help you ease into the process, and gradually increase the complexity and individuality of your projects. The three levels are:
Guided Projects - This is from a course where you follow along with the instructor on the project. Like this video: Full Project in Excel | Excel Tutorials for Beginners from Alex the Analyst where he walks you through an Excel project.
Popular Projects - These are popular data projects like analyzing the titanic dataset. There are a lot of resources on these projects and examples to look at.
Personal Projects - These are typically more unique and individual. You either create your own dataset or find a (different) dataset to analyze. Check out this project from Abe Diaz where he analyzes his performance in a Brazilian Jiu Jitsu tournament.
Once you get comfortable with level you move onto the other, so eventually your portfolio is filled with personal projects. If you want more guidance on building a portfolio check out my blog post: A Guide to Creating a Well Rounded Data Analytics Portfolio.
Revisit Old Queries to Improve them
Now this is a bonus tip: go back to old queries to improve them. This helps you not only make old queries more efficient but you can also sharpen your problem-solving skills, understand your learning journey, and stay up-to-date with best practices in SQL. It lets you:
Identify and learn from past mistakes, recognizing your SQL journey.
Apply new techniques or functions that you may have learned since you first wrote the query.
Optimize performance by re-writing your queries. This is a crucial skill to have professionally where efficiency can impact scalability and cost.
Enhance readability and maintainability, making your code easier for others (and your future self) to understand.
Stay engaged with past projects, keeping the knowledge fresh and potentially sparking new ideas for analysis.
During your job search you may be asked to do a technical interview where you are assessed on your technical skill and problem solving for a role (for more information on this check out my blog post). While technical interviews aren’t always realistic for what you do in a data role they are great practice. If you can, I’d suggest doing at least one mock interview focusing on SQL. This way you can get practice thinking on your feet and coding live. While most data jobs don’t require live coding there may be times when you have to work with your colleagues and write SQL in real time. Either way, it’s good practice. Personally, my mock interview helped me identify where I needed to improve and gave me feedback on my SQL knowledge. You can join communities like Data in Motion where they have experienced data professionals offer advice or give mock interviews. You can also network with other professionals on LinkedIn. See if anyone is willing to go through a mock interview with you. I'd suggest doing this with people who you've built a relationship with. Meaning, don't ask people right away if they can give you a mock interview.
Below are some key takeaways from this article:
Start your SQL learning journey with structured tutorials and courses to build a foundation.
Practice SQL problems regularly to develop problem-solving skills and understand SQL logic.
Work on projects to apply SQL in real-world scenarios, starting with guided projects and moving towards personal ones.
Revisit old queries and refine them to improve your efficiency and understanding.
Prepare for technical interviews with mock sessions to enhance your ability to code under pressure.
Stay updated and continuously learn to adapt to the changing landscape of data analytics.
Mastering SQL is a journey of continuous learning and practice. No matter how much you know, you can always learn more. But starting with tutorials and courses, moving onto practice problems, and applying your knowledge to increasingly complex projects, you can build a better understanding of SQL. Remember, the key is being able to apply and reapply your knowledge to real-world problems. Even when you have a job, keep learning. Data analytics is an ever changing field and you need to stay as up-to-date as possible.
If you want a full guide on how to become a data analyst check out this post. Or if you’re interested in resources I’d recommend for learning data skills or staying up-to-date on data news check out my resources. Want more advice on how to learn new skills? Check out one of my older blog posts: Struggling to Learn New Skills? Here's Advice From Top Learners on How to Learn Quickly.