Perhaps you have started your SQL journey by trying to read a beginner SQL book from start to end. In fact, if you feel that this is slow and frustrating, you’re not alone. Similarly, I worked for 7 years as a business analyst without finishing any beginner SQL books! Instead, you will learn faster by looking at sample code written by analysts in your company.
Generally, the first 1-2 chapters of a beginner SQL book describe the history and design of databases. However, such information might be out-of-date, especially if your company is at the forefront of e-commerce. Specifically, many companies are moving beyond traditional databases and capturing unstructured data as well. Consequently, new forms of data management (e.g. NoSQL and data lakes) are emerging.
For the purpose of analyzing business performance, it won’t be mission-critical for you to understand the nuts and bolts of data storage and processing. This is because (fortunately) your company should have data engineers to process the data into tables that you can easily analyze.
Anatomy of a SQL query
A query is a piece of code that you use to pull data out of an existing database, which consists of multiple tables. These tables would already have been populated and maintained by your database engineers. Usually, the queries that you see will look like this (standard SQL keywords in red):
As a result, you’ll want to focus on the core concepts captured by the 4 keywords above. For that reason, you will need to read 4-5 chapters of your textbook before being able to do anything useful! Nonetheless, don’t be discouraged – this can go quite quickly if you try to read and understand an actual query from your company, side-by-side with the book. To this purpose, the most useful chapters will be in the middle of the book and cover these concepts:
- Structure of a basic query (SELECT – FROM – WHERE)
- Different ways of filtering information (WHERE)
- Aggregating data in multiple rows (aggregation functions with GROUP BY)
- Joining different tables (JOIN, LEFT JOIN, RIGHT JOIN, OUTER JOIN)
What’s a good beginner SQL book to get started with?
Although I lacked the time to read SQL books while working, I’m now between jobs and have more time. Hence, I used this opportunity to skim through the beginner SQL book titles that appear most often in online recommendation lists. In summary, the subject matter in all the books was fairly similar, so you can choose depending on the style you prefer. Despite the advancements in database technology, SQL keywords and syntax – and the concepts behind query structure – have remained fairly constant over time. Accordingly, you might even be able to find an older edition of one of these books online for free, and it would still contain everything you need as a business user!
|Learning SQL: Generate, Manipulate and Retrieve Data||Alan Beaulieu||3rd, 2020||Concise|
|Sams Teach Yourself SQL in 10 Minutes||Ben Forta||5th, 2019||Conversational|
|SQL Quickstart Guide: The Simplified Beginner’s Guide to Managing, Analyzing and Manipulating Data with SQL||Walter Shields||2019||Conversational|
|SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL||John Viescas||4th, 2018||Conversational|
|Getting Started with SQL: A Hands-On Approach for Beginners||Thomas Nield||1st, 2016||Concise|
What version (s) of SQL to focus on?
As you browse through different books, you’ll come across many versions of SQL – MySQL, T-SQL, PostgreSQL, etc. Actually, the version of SQL you use at your workplace might not even be technically called “SQL” at all! In fact, if your company is using “big data” stored in Hadoop or on the cloud, you’ll probably be using a SQL-like query language called Hive, or its open-source counterpart named Presto.
However, all these languages use almost the same keywords and syntax for pulling data from existing databases. So for a business user, the version of SQL covered in a particular book will be immaterial, with a few small exceptions that will be covered in later posts. The differences are more relevant for the developers who build and maintain your databases.
Key actions and take-aways:
- Find an actual SQL query for a metric that is the most important to your daily work. Compare the structure of the query to the outline in this post.
- Browse the reviews / previews of a few beginner SQL books. The book titles in the table above are hyperlinked to Google Books pages containing information & previews of the books.
- Use the SQL book as a companion reference, rather than trying to read through it sequentially before examining the actual query.