Back to articles list Articles Cookbook
8 minutes read

Why Should Every Data Analyst Know SQL?

In the 1980s and 90s, it was the emergence of ERPs, processing a few thousand transactions a day. Now, sophisticated Cloud-based systems work with billions of transactions each day. How data is captured and handled has come a long way!

Anybody who understands how to use this data has an edge. The good thing is that while the technology working in the background has become more complex, we don’t necessarily need to understand the underlying system’s details to use it. There are simple yet powerful tools you can leverage to drive business growth, make more profit, or get that next promotion.

Being able to use SQL effectively is one of the most important data analysis skills. It’s no wonder that when we asked LearnSQL.com users why they wanted to learn SQL, most replied that they were data analysts and wanted to learn SQL to expand their skill set.

But before I explain why a data analyst should learn SQL, let me take you through what data analysis is and who data analysts are.

What Is Data Analysis and Who Is a Data Analyst?

Data analysis refers to using and manipulating data to generate insights that can help businesses solve a problem or uncover opportunities.

A data analyst is anyone who performs data analyses. Many companies today have “data analyst” as a formal job title. The typical responsibilities of a data analyst include cleaning/transforming data, modeling it in specific formats, and creating visualizations or views to highlight information that can be used by decision-makers. You can check out this article to understand the skills a data analyst needs.

Data analysis jobs have gained a lot of traction in the last few years and pay quite well.

However, irrespective of the job title, many people use data analysis in their daily work. Almost anyone can benefit greatly from learning data analyst-type skills like SQL.

data analyst

Historically, MS Excel was sufficient to handle these activities. But as businesses generate more data, something more than a spreadsheet is needed to keep up with the pace. And that is where SQL enters the picture, specifically when it comes to dealing with relational databases storing large volumes of data.

Why Is SQL Important for Data Analysis?

SQL is the language used to interact with relational databases. Since most systems today capture the data using one or more databases (like MySQL, Oracle, Redshift, SQL Server, etc.), you need to know SQL to extract data from these systems and then work with it.

The good thing is that since the SQL syntax used by most of the databases is standardized, you don’t need to learn a language specific to each database; you can learn SQL once and then make small adjustments as you work with multiple databases.

Another great thing about SQL is that it’s usually quite fast. It can work with large volumes of data; the database engine is tuned so that you don’t wait forever to get the results. In fact, a well-written SQL query can fetch results from a few million rows within a minute.

In addition to that, SQL queries you write are repeatable and scalable. You can write a query once and then reuse it again and again. As the data increases in your database, you don’t need to change much in your query to accommodate similar results. In fact, even if new tables are added, you can use the previous query and make a few changes; it should still work just fine. Databases also generally support scalability for adding new data – e.g. easily increasing storage in the background or processing power – especially when they are Cloud based.

So is such a powerful and flexible language hard to learn? No! SQL is close to the English language and its syntax is easy to understand. If you practice a few queries every day, you can master it in no time.

Let me take you through a practical business example of how SQL can be used to generate some powerful insights.

SQL Analysis: A Practical Example

Imagine that you have started a new internet-based company selling exotic varieties of tea online.

After your first 12 months of business, you have acquired 100,000 customers and have sold $1,000,000 worth of products. That seems like a promising start. However, now you have a target to scale to $10,000,000 within the next two years.

Typically, you can increase sales by increasing the number of customers who buy your product or by selling more to existing customers. Let’s say that as a first step you want to generate more orders from your current customer base.

data analyst

Right now you have 100,000 customers who bought an average of $10 per order. One way to sell more to the same customer is to get them to buy more types of tea.

You can use SQL to start segmenting (or dividing) your customers into groups based on their purchase behavior. Say you want to divide customers into two groups:

  1. Loyalists who buy only 1-3 types of tea.
  2. Variety Shoppers who buy more than 3 types of tea.

The goal is to advertise new products to the Variety Shoppers so that you can 1) unlock a higher frequency of orders for different items, or 2) generate more value per order from more items in customers’ carts. You could offer quantity deals to Loyalists for similar products. By quantity deals, I mean special offers if they buy more of the same product.

Your data is stored in two database tables:

The Orders Table:

Order_IdProduct_NameCustomer_IdTotal Value
21Tea-Green21223$25

The Customers Table:

Customer_IdCustomer_NameSexCity
21223AngelaFMilan

Here’s the query you’d write. Don’t worry if you don’t understand it; we’re just focusing on the results obtained from this relatively short piece of code:

SELECT b.Customer_Id,
	 b.Customer_Name,
	 CASE
	      WHEN Count(Distinct a.Product_Name) > 3 THEN 'Variety Shopper'
	      ELSE 'Loyalist' END as Category
FROM Orders a
JOIN Customers b
  	  ON a.Customer_Id = b.Customer_Id
GROUP BY b.Customer_Id,
         b.Customer_Name;

And here’s the result of this query:

Customer_IdCustomer_NameCategory
21223AngelaLoyalist
21224RickVariety Shopper
21225AhmedLoyalist

The query basically joins the tables Customers and Orders and then counts the different types of products ordered by each individual. Finally, based on that count, we assign a category (Loyalist or Variety Shopper) to each customer.

Now you can use this list to send targeted and personalized offers to each individual depending on their purchase behavior.

You can use SQL later to measure the performance of this campaign. All you need to do is get the total sales from these tables and the average value per order for each category and then see if it is growing.

This example is just the tip of the iceberg. You can use SQL for other powerful analyses in marketing analytics, sales, finance, HR, and operations. If you are new to SQL, our SQL Basics course will help you get started.

All in all, SQL offers many opportunities for you to use data to make decisions. It also allows you to structure the measurement of results and then come up with continuous improvement initiatives. But why learn SQL rather than some other tool or programming language that can do similar things?

SQL vs. Excel, Python, and Java

Indeed, that is the right question to ask. And I am not denying the usefulness of Excel, Python, Java or any other solution. All these are quite powerful. However – given the simplicity of learning and the kind of results you can derive – SQL is a must-have for data analysts. In fact, all these tools have libraries or functionalities that help you connect to a database and execute SQL statements.

Also, SQL has an edge over Excel when it comes to volume. SQL is much faster and much easier to scale. Compared to Java or Python, SQL is much easier to learn, especially if you don’t have an IT background. In fact, I would recommend learning SQL first and then learning Python if you want to further enrich your arsenal. I use both of these in my data analysis work and together they cover most functionalities.

How to Start Learning SQL

Now you’ve realized why it is important to learn SQL. The next step is to actually start learning it.

We are lucky to live in a time where we have abundant online learning resources. My recommendation is the A to Z SQL track from LearnSQL.com. It covers everything you need to start using SQL professionally: queries, reports, beginning and advanced statistical functions, and more. The individual courses are well structured, have ample practice lessons, and cover every concept comprehensively.

data analyst

To start learning SQL on this platform:

  1. Create a free LearnSQL.com account or log in if you already have one.
  2. Start your selected course. You can choose Standard SQL or one of the following dialects: PostgreSQL, MySQL, MS SQL Server.
  3. Start being awesome!

If you prefer learning from physical books, then you can find some options here.

In my opinion, spending 1-2 hours daily for a few months can give you enough to start using SQL for practical purposes. This is just an average estimate; you may be able to do it much faster!

So, get started today and happy learning!