SQL for MarketersSQL for Marketers
Learning SQL and Bringing You Along
In a break from our usual posts about advanced SQL techniques, we’re bringing it back to the very beginning.
Jon Bishop recently joined Periscope to scale our marketing. This blog post is the first in a series he’s writing as he learns SQL.
One of the first things I did when I joined Periscope was dig into our product. That means digging into our dashboards, testing our sharing features and creating SQL charts.
Many of our customers are hardcore data analysts who love the flexibility that raw SQL brings. And of course, we do all of our analytics in Periscope.
So not only is SQL important for understanding our product and our audience, it’s also what our own analytics are written in.
Only one problem: I don’t know SQL!
So join me for an adventure in learning SQL from a marketer’s perspective.
Introducing Our SQL for Marketers Series
Data helps a marketer be better at her job. Many marketers use tools like Google Analytics and Mixpanel to manage their marketing and product data.
Yet these tools have their limits, whether it’s the way the metric is defined or the way the product was built. This is where SQL comes in. It lets you look at any data you want and gives you a greater understanding of how your data works.
Almost all websites and apps have a database where they store their data. Most of these databases speak SQL, which for stands for Structured Query Language.
SQL is a programming language designed for managing the data held in your database. You can think of it as the language you use to ask questions of your database.
Common SQL Terms
Some of the common terms you’ll come across:
- Database — A database is an organized collection of data. It’s where you store your customer, order and any other data.
- Query — Queries are the primary way of grabbing information from a database and consist of questions presented to the database in a predefined format.
- Console — The console is where you’ll type in your SQL code.
- Table — A table is a collection of related data held in a structured format in a database.
- Column — A column is a set of data values, one for each row of the table. The columns provide the structure according to how the rows are composed.
- Row — A row in a table represents a set of related data, and every row in the table has the same structure.
Basic SQL Commands
- select — This is the starting point for most SQL queries you’ll run. Select tells your database to give you data. For example if you want every bit of data, you type select *. Or if you want a specific column from your customers table, you could type select customers_table.created_at (where the table is customers_table and the column is created_at).
- from — After you’ve typed the data you want to select, you need to tell the database what table that data lives in. For example, if you want data from your customers table, you’d type from customers_table.
- where — Often, you don’t want every piece of data in your tables, instead you filter the data. This is what where is for — it either includes or excludes data. For example, if you wanted data on customers who joined after 5/03/14, you’d type where customers_table.created_at > '2014-05-03'
- join — Many times, you’ll have data you want to analyze in two different tables. For example, you may have one table with your customer data and another with all of your order data. If you want to combine the data into one temporary table, use join.
Resources for Learning
Below are some resources for learning more about SQL in between our lessons:
Next time, we’ll jump into more detail about SQL queries for grabbing data, keeping unwanted data out of your charts and segmenting data.
Sign up for our blog updates to get future lessons in your inbox!