14th Oct 2021 8 minutes read Still Using Excel for Data Analysis? See Why SQL Is Better! Kateryna Koidan learn sql data analysis Table of Contents What Is SQL? Why Choose SQL Over Excel? SQL Use Cases Use Case 1: Marketing Campaigns Use Case 2: HR Research Use Case 3: Credit Portfolio Analysis It’s Time to Learn SQL! Are you working with data and still using spreadsheets? Many people think that only programmers or professional data analysts can leverage SQL for data analysis. In this article, I’ll show how people with no IT background can use SQL for their daily work tasks. Not all people working with data have the corresponding job titles like data scientist, data analyst, or data engineer. Following the data democratization trend, almost all office workers do something with data as part of their daily duties – marketers analyze advertising campaigns, HR specialists analyze employee dynamics, auditors analyze credit portfolios, etc. Out of habit, these people often use Excel or Google Sheets. They may not even know that there is a more efficient alternative, such as SQL. What Is SQL? SQL, or Structured Query Language, is very commonly used to communicate with relational databases, which are the standard tool for storing large amounts of data. These databases store data in tables, which can be related to other tables in the database through common fields. Let’s say Facebook has a table with users, a table with posts, and a table with activities (i.e. likes, comments, etc). The activities table is likely to reference the ID of a corresponding user and a corresponding post; this refers to the relevant records in the user and post tables. These connections allow us to pull information from different tables quickly and efficiently. For example, with one simple query, you could gather the information on all users commenting on a certain post. You can use SQL to: Create databases and tables. Add data to a table. Select, edit, delete, or sort data. Find unique values. Combine data from two or more tables. And more! Would you like to try SQL yourself? You can start your journey with our interactive SQL Basics course. Why Choose SQL Over Excel? There are several myths that discourage non-professional data analysts from looking into SQL. Here are some of those: You need an IT background to use SQL – False. Even though SQL is a programming language, it doesn’t require any experience in IT. You can learn SQL and use it for your data analysis without becoming a developer. It is difficult to learn SQL – False. SQL is beginner-friendly and easy to use. When coding in SQL, you are basically using the English language to “talk” to a database. All you need to learn is how to structure your queries. SQL is only used with Big Data – False. Major tech players like Google, Uber, and Facebook use SQL to analyze the terabytes of data they produce, but SQL can be an extremely handy tool for just about any business. Read this article to see how SQL works with small datasets. You shouldn’t be scared of SQL. But why switch from something you already know well (like Excel) to something totally new (like SQL)? With SQL skills, you are no longer dependent on data engineers to get your data from a database to a CSV file. You can get any data you want by experimenting with different queries, without waiting for technical staff to help you. Next, SQL is often better than Excel because it is much more efficient. For example, it’s easier to replicate an old analysis with new data using SQL. You can just save your queries and run them again at any time. Are you preparing a weekly sales report? You probably have a long step-by-step guide for doing this in Excel: Import data, sort data, filter certain values, delete unwanted rows, and so on. With SQL, you just run the same code every week; you’ll have the report ready in moments! Finally, when considering SQL vs. spreadsheets, remember that SQL is much more efficient with large datasets and less prone to accidental data changes. Plus, it provides greater flexibility when you’re combining and analyzing business data. You can read more about SQL’s advantages over Excel in our earlier post Why Use SQL Over Excel. Now, let’s move on to some practical examples. SQL Use Cases With the amount of data available these days and all the tools we have to leverage it, it’s obvious why data-driven companies are leading the competition. To become a part of a data-driven company or to contribute to the data transformation of your company, you should be familiar with the most efficient tools for working with data. SQL is definitely one of these tools. Let’s examine three use cases to see how office workers (who are not professional data analysts) can leverage SQL in their daily work. Use Case 1: Marketing Campaigns Let’s imagine a marketer who has to develop a target audience for their next email campaign. They have a large database of customers, but the campaign should be sent only to those who: Purchased at least $500 within the last year. Ordered items from the Kids category. Subscribed to promotional campaign emails. That’s not an easy task in Excel – filtering thousands of records, combining several large tables using VLOOKUP or similar, waiting for Excel to process all these operations, periodically checking that each step performed as intended – and hoping that no major mistakes were made. It’s much less challenging and time-consuming after you master SQL. In one SQL query, you can select the customers that satisfy each of the conditions and then join these tables to get the final target audience for your marketing campaign. It takes only moments to get the output! And you can use the same query again if you have a similar marketing campaign next month. Or you can slightly modify your query (e.g. by changing the item category or the amount threshold) for another marketing campaign. Use Case 2: HR Research HR specialists can also benefit from using SQL. Let’s say you are an HR analyst and you were asked to shortlist some sales representatives for promotion. The candidates should meet several conditions: They have at least 3 years of experience within the company. They are in the top 10% of sales results for the last year. They have excellent leadership skills, according to the last annual evaluation. To get the shortlist, you’ll need to combine data from several different sources, do lots of filtering, and perform some complex calculations. That would be a very labor-intensive and time-consuming process in Excel. Alternatively, you could run an SQL query that will quickly combine information from several database tables and return the list of candidates. Of course, to write such a query, you'll need SQL skills that are beyond the basic level. The SQL from A to Z learning track is a perfect choice for those wanting to efficiently work with any type of data. Use Case 3: Credit Portfolio Analysis For the last example, I’ll tell you about a real use case I faced when starting my career as an internal auditor in a large retail bank. The bank had a huge mortgage portfolio with a high percentage of bad loans following the 2008 crisis. As internal auditors, we were tasked with analyzing the quality of credit portfolios across different regional branches. To get full information on each loan, we had to combine data from many different sources: basic information on the borrower, data on the latest payments, available collateral and its quality, and so forth. Unfortunately, at those times, none of us had any experience with SQL and we were doing our analysis in Excel. I remember this task took us several weeks of painstaking work with a slow VLOOKUP tool, numerous Excel failures, and endless manual checks. Now I know that, with someone writing a couple of smart SQL queries, we could’ve saved weeks of our team’s work. It’s even more enjoyable to be that “someone”. So, let’s get started on that! It’s Time to Learn SQL! In this article, I’ve shown just a few examples of how SQL can be used to address real-world work tasks. Of course, SQL has many more tools that make data analysis easier and faster. You can find examples of using SQL to calculate revenue growth and customer lifetime value elsewhere in our blog. Now that you understand how valuable SQL is and how it can boost your career, let’s see how you can learn SQL in the most efficient way. Even though SQL is easy to learn, it’s very important to find a good source of education. I recommend starting with the LearnSQL.com SQL Basics course. It includes 129 interactive exercises that cover simple queries, selecting data from multiple tables, aggregating and grouping data, joining several tables, writing subqueries (i.e. queries within queries), and more. For those willing to go beyond the basics, I recommend the SQL from A to Z track. It includes 7 interactive courses covering various SQL concepts, including such advanced topics as window functions, common table expressions (CTEs), and recursive queries. Obviously, having SQL expertise onboard is very beneficial for the company. So, you should definitely try to convince your boss that you need to start learning SQL; maybe you’ll be lucky and get your education financed by your company. Thanks for reading, and happy learning! Tags: learn sql data analysis