
Dan Patiño
AI Strategy & Innovation at Coderhouse
Data
The Most Common Mistakes When Learning SQL That Slow Down Data Analysts' Progress
Published on
SQL is the language that opens the door to data analysis, but some conceptual mistakes slow down the progress of those who are just starting. Most are not syntax errors, but misunderstandings about how the query works. Here we review the most common ones with concrete examples and how to fix them.
Mastering these points well saves you hours of frustration and slow queries. The official documentation of PostgreSQL and guides like those of Mode are excellent references to solidify concepts. If you come from spreadsheets, this bridge on SQL for analysts coming from Excel is useful.
Mistake 1: confusing WHERE and HAVING
The most classic. WHERE filters rows before grouping; HAVING filters after grouping, over the results of aggregate functions. If you want to filter by a count or a sum, HAVING goes. Using WHERE for that gives an error or incorrect results.
Mistake 2: poorly applied JOINs
Choosing the wrong type of JOIN distorts the results. An INNER JOIN discards rows without a match; a LEFT JOIN keeps them. Confusing them makes data "disappear" without you realizing it. Before writing the JOIN, ask yourself which rows you want to keep.
INNER JOIN: only rows with a match in both tables.
LEFT JOIN: all of the left ones, whether they match or not.
Duplicates: a poorly built JOIN can multiply rows; check the keys.
Mistake 3: unnecessary subqueries
Many solve with nested subqueries what a JOIN or a window function would do in a clearer and faster way. Subqueries aren't bad, but overusing them makes the query slow and hard to read. If a query has three levels of nesting, there's almost always a simpler way.
Mistake 4: not using aliases
Without aliases, queries with several tables become illegible and prone to ambiguity errors. A good short and descriptive alias makes your SQL easier to understand and maintain, both for you and for your team.
Mistake 5: forgetting performance
Querying SELECT * over enormous tables or not taking advantage of indexes are mistakes that don't fail, but make everything slow. As you grow, thinking about which columns you request and how the data is filtered makes the difference.
Recommended Coderhouse course
To learn SQL well from the start and avoid these mistakes, these training programs cover different levels:
SQL Course: the fundamentals of the language with guided practice.
Data Analytics Course: to apply SQL within a complete analysis flow.
Data Scientist Career: the advanced path for those who want to go beyond analysis.
Frequently asked questions
What's the most common mistake when starting with SQL?
Confusing WHERE and HAVING. Remember: WHERE filters before grouping and HAVING after, over aggregate functions like COUNT or SUM.
When do I use a JOIN and when a subquery?
In general, a JOIN is clearer and more efficient for combining tables. Subqueries are useful for specific cases, but it's a good idea not to overuse them.
Is it serious to use SELECT *?
It doesn't fail, but it brings all the columns even if you don't need them, which makes the query slower. Request only the columns you're going to use.
How long does it take to learn SQL to analyze data?
With constant practice, in a few weeks you can make useful queries. Mastering JOINs, aggregations, and window functions takes a bit more, but it's very achievable.

About the author
I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.