This month's TTYSK: SQL Query

What’s a SQL query? What does it mean to join tables? Heck, what are tables?! Here's what you need to know (and don't need to know) about SQL queries as a PM.

Every month I teach a Tech Term You Should Know (TTYSK) to level up your technical literacy and communicate confidently with dev teams.

👉 📬 What technical terms would you like me to cover? Ask me anything and I'll cover it in an upcoming issue.

You’re in a meeting, and an engineer says, “If you want to get data on how many mobile users are dropping off, we’ll have to create a SQL query. We’ll probably need to join the users tables with the events table to filter by active accounts and group them by device type.”

You nod, but truthfully, you’re lost.

What’s a SQL query? What does it mean to join tables? Heck, what are tables?!

TL;DR: What you need to know about SQL queries as a PM

💡 SQL queries allow engineers to interact with SQL/relational databases to retrieve, create, update, and delete data.
👀 SQL retrieval queries are used to retrieve specific data from a database table.
👀 SQL queries are made up of commands and clauses that work together to retrieve, manipulate, and manage data within a SQL database.
 While not every role will require you to write SQL, being able to write simple SQL queries has many benefits including setting you apart during interviews.

📌 Save this for your next meeting with your engineering team or interview. It will come in handy.

First, what’s SQL?

SQL (Structured Query Language) is a language used to interact with SQL databases. Most databases that use SQL are relational (e.g. MySQL, Postgres, etc), meaning they store data in structured tables with predefined relationships. You can think of a SQL table as an excel spreadsheet. Each table has:

  • Columns that define the type of information stored (e.g., product name, price, purchase date).

  • Rows that hold individual records (e.g., each order or customer).

In contrast, non-relational or NoSQL databases do not store data in tables and do not use the “table” format.

For example, here’s an example of what a SQL database table might look like for an e-commerce store selling electronics:

id

product_name

purchase_date

customer_name

price

1

Laptop Pro

2024-03-15

John Doe

1299

2

Wireless Mouse

2024-02-28

Jane Smith

49

3

Monitor 4K

2024-03-10

Bob Johnson

599

There are 5 columns in this table:

  • id: The unique id for each item

  • product_name: The name of the product

  • purchase_date: The date the product was purchased

  • customer_name: The name of the customer that purchased the product

  • price: The price of the purchased product

Each row then represents each item that was purchased. For example, John Doe bought a Laptop Pro for $1,299 on March 15th, 2024.

What is a SQL Query?

A SQL query is a statement request that you send to a SQL database to perform an action to retrieve data, insert new data, update existing data, or delete data.

For example: As a PM, you may want to track the performance of your app, generate reports on your customers, or extract business insights from data. In order to do this, data needs to be retrieved (or “pulled”) from the database in order to create reports and get metrics information. This requires writing SQL queries that return specific data from a SQL database, also known as retrieval queries.

What’s the structure of a SQL query?

SQL queries are made up of commands and clauses—instructions that tell the database what data to retrieve, how to filter it, and how to organize the results. A command tells the database to perform an action. A clause then refines or modifies the command.

Let’s see how this works by breaking down an example.

Imagine you’re a product manager at an e-commerce store selling electronics and you want to find out which products were most popular with customers in Q2 of 2024.

Since the data is stored in a Postgres database, a SQL query needs to be written to get the product names and purchase dates for all products purchased after March 1, 2024. The SQL retrieval query might look something like this:

SELECT product_name, purchase_date 
FROM orders 
WHERE purchase_date > '2024-03-01'

This simple SQL query is made up of the SELECT command, and the FROM and WHERE clauses. Together the command and clauses creates a SQL query statement that returns us the data we’re looking for.

Here’s how the above query works:

1️⃣ SELECT command: Defines what data about each item in the database you want the query to return. In this example, the query will return the product name from the “product_name” column, and the date the product was purchased “purchase_date” columns.

2️⃣ FROM clause: A database is made up of many tables, so the FROM clause specifies which table to pull data from. In this case, it tells the database to look in the Orders table.

3️⃣ WHERE clause: Filters and return all the results based on a condition. In this case, only products purchased after March 1, 2024.

There are many types of commands and clauses

In the above example, you briefly learned about 3 commands and clauses: the SELECT command, the FROM clause, and the WHERE clause, but there are many more that can be used to create a SQL query. Here are some of the most common ones:

You don’t need to memorize them all. Just having a general idea of what’s available is helpful enough context for data discussions with engineers.

Benefits of understanding SQL queries

As a product manager, you work with data all the time—user behavior, feature adoption, conversion rates, and more. While you won’t always be required to write SQL, having an understanding of how SQL queries work will help you:

🚀 Ask better questions: Asking better questions means asking questions that show you are well-informed and have a strong technical foundation. For example:

  • 🔄 A non-technical PM might say: "This number looks low. Can we double-check if the tracking is correct?"

  • ✅ A technical PM might say: "This number looks low. Can we check the query logic? Could there be missing rows because we’re not filtering out inactive users or only counting first-time interactions?"

💬 Have more productive conversations with engineers: When engineers talk about various commands and clauses, you’ll know exactly what they mean. If they say, "We need to adjust the SQL query to filter out inactive users”, you'll understand the change and contribute to the discussion faster.

🎯 Make more informed decisions: Let’s say you just released a beta feature, and you want to look at engagement and adoption before hard launching the feature. To get this data, you could query how many users interacted with the feature during the beta period and cross-check it with feedback you received.

Final thought

Depending on where you work, you may or may not be asked to write SQL queries. However, knowing the basics of writing SQL queries is very beneficial for a few reasons:

  1. You have more freedom and independence to run reports yourself without having to wait for engineers to do it for you.

  2. It’s a big plus on your resume and will set you apart from other product managers when interviewing for new roles.

Regardless, having a basic understanding of how SQL queries work will help you communicate better with engineers.

How helpful was this TTYSK? Why or why not?

Login or Subscribe to participate in polls.

Want to feel more confident in your technical skills?

Become more technical in just 4 weeks, without learning to code!

As always, connect with me on LinkedIn and Twitter and follow Skiplevel on LinkedIn, Twitter, and Instagram.