Basic SQL Skills for Product Managers

Thaisa Fernandes⚡
Jun 3 · 8 min read

Data is a powerful tool for Product Managers. We all know that corporations should use data to run their business and make the decision process easier. When any type of data is involved in the process, databases are used in every single aspect of it.

You might be wondering, should I become a database expert? I say, you won’t need to. The most popular language used for manipulating data from a database is SQL, and you don’t need to be an expert to manipulate the database to generate reports and analysis.

Keep in mind that around you, everyone is using SQL to drive these databases. But where? I’d say, everywhere from your phone to your computer, from the social networks you use, to softwares. They’re all using SQL when managing data.

Learning SQL will teach you how to manipulate the data to get the information you need. You will learn how to interact directly with your database. I’m sure your team will feel extremely grateful if you gather the data by yourself without bothering them. Don’t forget to ask them for the access and check your permissions.

By Programming with Mosh

What’s SQL?

SQL is an acronym for Structured Query Language, and it’s also referred to as “sequel.” They’re the same thing, and people use both terminologies. SQL is the language that allows communication with the database with the objective of managing the data it contains.

SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS) or for stream processing in a relational data stream management system (RDSMS). It is particularly useful in handling structured data where there are relationships between different entities and variables of the data — Wikipedia.

The acronym CRUD refers to: Create, Retrieve, Update, and Delete data from a database. You will probably be mainly interested in the ability to get the information you need from the database that corresponds to the letter R of CRUD. The other letters (C, U, D) are typically the responsibility of Engineers and DBAs and not as relevant to PMs.

MySQL and PostgreSQL databases

MySQL and PostgreSQL are popular open source databases. Their database type is known as a ‘relational database’, a set of multiple data sets organized by columns, tables, and also records. Each table is known as a ‘relation’, and the data stored as tables has its own number of columns and rows and represents a set of data.

In a relational database, the tables can communicate with each other in the same way an Excel or Google spreadsheet works. In the database, the tables communicate based on specific fields known as ‘keys.’

Both MySQL and PostgreSQL are DB software, and their usage is very similar. They’re open source, which means that the original source code is freely available and publicly accessible.

The main differences between the two are how they organize the data internally and some optimization tools, but their usage of SQL is pretty much identical. One big difference is that PostgreSQL is case sensitive.

How can I use it?

You can measure results and set metrics without needing to involve your engineering team to gather the data you need. This capability can be really handy especially if you work in lean teams.

For PMs, the understanding of where the data lives can lead to a deeper knowledge of your product and its flaws. You can help the team make sure relevant fields are added to the table so you and your team can generate better reports and analyses.

The process of retrieving information from a database is called ‘querying’ a database. After querying the database, a result is known as a ‘result set.’ The result is the answer to your query.

How do queries work?

The whole point of a query is basically to describe exactly what information your application needs, potentially joining together information from several sets of documents, and then being able to generate a response that contains only the exact fields you need.

SQL queries allow you to find things like:

  • A list of bank customers eligible for a new credit card;

Connecting to a database

There are various ways to connect to a SQL database. Remember that before you can connect to a database, you’ll need some information such as username, password, server address, protocol, and port. Check with your engineering team, they’ll be able to grant you access!

SQL SELECT statement

The SELECT statement is used to select data from a database. The data returned is stored in a result table, and it’s called the ‘result-set’.

The basic syntax for the SELECT statement, when used in a SELECT statement, is as follows.

SELECT column1, column2….columnNFROM table_name;

Check the examples below, they were inspired by sqlzoo.net. The example uses a WHERE clause to show the population of Brazil.

SELECT population FROM worldWHERE name = ‘Brazil’

You can use WHERE name LIKE ‘B%’ to find the countries that start with “B”.

SELECT name FROM worldWHERE name LIKE ‘B%’

How to use WHERE to filter records. Show the name for the countries that have a population of at least 200 million. 200 million is 200000000, there are eight zeros.

SELECT name FROM worldWHERE population = 63206900

List each country name where the population is larger than that of India.

SELECT name FROM worldWHERE population >(SELECT population FROM worldWHERE name=’India’)

Find the largest country (by area) on each continent, show the continent, the name and the area:

SELECT continent, name, population FROM world xWHERE population >= ALL(SELECT population FROM world yWHERE y.continent=x.continentAND population>0)

SQL WHERE clause

Every programming language follows a unique set of guidelines termed syntax. Punctuation, spaces, mathematical operators, and special characters have special meaning when used inside of SQL commands and query statements. Check more information about it here.

SELECT * FROM tableName WHERE condition;

The following SQL statement selects all the customers from the country “Pakistan”, in the “Customers” table:

SELECT * FROM CustomersWHERE Country=’Pakistan’;

The following SQL statement selects all the customers from the subscription “Paid”, in the “Subscription” table:

SELECT * FROM CustomersWHERE Subscription=’Paid’

The following DELETE statement removes only those rows from table mytable where the column mycol is either NULL or has a value that is equal to 100.

DELETEFROM mytableWHERE mycol IS NULL OR mycol = 100

IN will find any values existing in a set of candidates.

SELECT ename WHERE ename IN (‘Paid’, ‘Free’)

BETWEEN will find any values within a range.

SELECT ename WHERE ename BETWEEN ‘Free’ AND ‘Pro’

SQL Syntax

Every programming language follows a unique set of guidelines termed syntax. Punctuation, spaces, mathematical operators, and special characters have special meaning when used inside of SQL commands and query statements.

SQL SELECT Statement

SELECT column1, column2….columnZFROM table_name;

SQL DISTINCT Clause

SELECT DISTINCT column1, column2….columnZFROM table_name;

SQL WHERE Clause

SELECT column1, column2….columnZFROM table_nameWHERE CONDITION;

SQL AND/OR Clause

SELECT column1, column2….columnZFROM table_nameWHERE CONDITION-1 {AND|OR} CONDITION-2;

SQL IN Clause

SELECT column1, column2….columnZFROM table_nameWHERE column_name IN (val-1, val-2,…val-N);

SQL BETWEEN Clause

SELECT column1, column2….columnZFROM table_nameWHERE column_name BETWEEN val-1 AND val-2;

SQL LIKE Clause

SELECT column1, column2….columnZFROM table_nameWHERE column_name LIKE { PATTERN };

SQL ORDER BY Clause

SELECT column1, column2….columnZFROM table_nameWHERE CONDITIONORDER BY column_name {ASC|DESC};

SQL GROUP BY Clause

SELECT SUM(column_name)FROM table_nameWHERE CONDITIONGROUP BY column_name;

SQL COUNT Clause

SELECT COUNT(column_name)FROM table_nameWHERE CONDITION;

SQL HAVING Clause

SELECT SUM(column_name)FROM table_nameWHERE CONDITIONGROUP BY column_nameHAVING (arithmetic function condition);

Logical operators

The Logical operators are those that are true or false. They return a true or false value to combine one or more true or false values.

AND

Logical AND compares between two Booleans as expression and returns true when both expressions are true.

OR

Logical OR compares between two Booleans as expression and returns true when one of the expression is true.

NOT

Not takes a single Boolean as an argument and changes its value from false to true or from true to false.

In case you want to dig into this a little deeper, below you’ll find more resources.




If you’re looking for PM goodies, don’t forget to check out my online store:

Check my online store here: https://society6.com/thaifernandes

👏 Clap once, 👏👏 clap twice, clap however many times you want.

Find out more about me @ my Portfolio, LinkedIn, Instagram, and Twitter. I’m building an app dedicated to women’s health. If you want to get early access, subscribe to the waiting list here. If you’re looking for PM goodies, check my online store too!

📩 Hey you. ⚡Join the PM 101 email list!

I send emails twice a month and I promise is really cool content :)

Click here to subscribe it


Disclosure: This post contains affiliate links and first-party promotion. If you click them and buy a product, I may get a small commission at no extra cost to you.

Product Management 101

PM learnings in my journey at Silicon Valley

Thaisa Fernandes⚡

Written by

Program Manager at Twitter Platform Solutions. Scrum Master & PMP Certified. Product Manager at Lunna App ♀️ she/her 💪 immigrant 🌱 vegan

Product Management 101

PM learnings in my journey at Silicon Valley

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade