Successfully reported this slideshow.
Your SlideShare is downloading. ×

SQL Tutorial for Marketers

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 52 Ad

SQL Tutorial for Marketers

Download to read offline

Technical marketers are in high demand and low supply. Being able to dive into data on your own, with no help from engineering, makes you a much better marketer.

This is why SQL is so powerful - it allows you to see any data you want about anything your customers do. Knowing how to use SQL is literally a marketing superpower.

In this SQL tutorial specifically for marketers, I've pulled together SQL query basics that any marketer or data analyst will need to dig into their customer analytics. This course is the best resource for marketers, growth hackers and product managers who want to get more technical and learn SQL. It's what I wish existed when I was going through tutorial after tutorial, sifting through lots of information that didn't apply to me and trying to learn on my own.

SQL is simple enough that - just by learning a few concepts I cover above - you'll be able to use it for any kind of data analysis, cohort analysis or campaign breakdown.

Want more information? Check out resources on my blog - http://justinmares.com/sql

Technical marketers are in high demand and low supply. Being able to dive into data on your own, with no help from engineering, makes you a much better marketer.

This is why SQL is so powerful - it allows you to see any data you want about anything your customers do. Knowing how to use SQL is literally a marketing superpower.

In this SQL tutorial specifically for marketers, I've pulled together SQL query basics that any marketer or data analyst will need to dig into their customer analytics. This course is the best resource for marketers, growth hackers and product managers who want to get more technical and learn SQL. It's what I wish existed when I was going through tutorial after tutorial, sifting through lots of information that didn't apply to me and trying to learn on my own.

SQL is simple enough that - just by learning a few concepts I cover above - you'll be able to use it for any kind of data analysis, cohort analysis or campaign breakdown.

Want more information? Check out resources on my blog - http://justinmares.com/sql

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Viewers also liked (20)

Advertisement

Similar to SQL Tutorial for Marketers (20)

Advertisement

SQL Tutorial for Marketers

  1. 1. SQL for Marketers and Growth Hackers Everything you need to know about using SQL for analytics, marketing and growth hacking
  2. 2. What is SQL? SQL is simply a language that makes it easy to pull data from your application‘s database.
  3. 3. What can you do with SQL? Answer questions!
  4. 4. Life without SQL Without SQL…. • You annoy technical people on your team • Hack together rough approximations for hours
  5. 5. Life with SQL “Starting in 2013, after the CMO realizes that he/she does not have the skill sets in place for data analytics proficiency, 50% of new marketing hires will have technical backgrounds.” - quote from IDC research of CMOs
  6. 6. Why is SQL important to me? SQL will help you see, understand and improve your company‘s metrics.
  7. 7. Why is SQL important to me? SQL will help you see, understand and improve your company‘s metrics. It allows you to access data other analytics tools cannot (Kissmetrics, Mixpanel, Google Analytics, etc.)
  8. 8. Do you know the answers to some very basic questions about your business? Take a Minute
  9. 9. Do you know the answers to some very basic questions about your business? – Are you getting more customers or less this month compared to previous? Take a Minute
  10. 10. Do you know the answers to some very basic questions about your business? – Are you getting more customers or less this month compared to previous? – What percentage of customers are active every week on your platform? Take a Minute
  11. 11. Do you know the answers to some very basic questions about your business? – Are you getting more customers or less this month compared to previous? – What percentage of customers are active every week on your platform? – How many users leave each week (churn)? Is this trending up or down? Take a Minute
  12. 12. Do you know the answers to some very basic questions about your business? – Are you getting more customers or less this month compared to previous? – What percentage of customers are active every week on your platform? – How many users leave each week (churn)? Is this trending up or down? – Who are your 100 most active users? Who are your 100 most valuable customers? Take a Minute
  13. 13. What can you do with SQL? • Make data-driven decisions • Run profitable campaigns using data • Understand every metric in your business • Get superpowers
  14. 14. How we improved churn with the help of SQL
  15. 15. Early Win for You! Let‘s take a second and have you do 2 things to get the most from this course: 1. Get read-only access to your database
  16. 16. Early Win for You! Let‘s take a second and have you do 2 things to get the most from this course: 1. Get read-only access to your database 2. Ask someone technical how to run queries against this database
  17. 17. A WORD OF CAUTION Only run queries on a read-only or “slave” database
  18. 18. How SQL Works A database works a lot like an Excel spreadsheet. It will contain multiple tables – all with unique names, like ―Customers‖ – with each table containing rows and columns
  19. 19. Why SQL is Better than Excel • Auto-updating information • Easier to query • Can visualize data automatically
  20. 20. Example Query *See how this query works by checking out the example database I pulled together at - http://bitly.com/udemysql
  21. 21. Example Query *See how this query works by checking out the example database I pulled together at - http://bitly.com/udemysql
  22. 22. SQL Queries Select — This command tells SQL what data you want to see. This data needs to be a part of the table you‘re accessing.
  23. 23. SQL Queries From — this command tells SQL where to pull the data from. What‘s the name of the table you‘re using to capture data? Put that after the ―from‖ statement.
  24. 24. SQL Queries Join — This command temporarily joins two tables we‘d like to search, so that we can pull data from multiple queries. ―Join‖ tells SQL which table we‘d like to join, and the ―on‖ modifier tells SQL which columns in those tables should map to each other.
  25. 25. SQL Queries Where — This statement tells SQL how to access the right data. In this case, we‘re telling it to show us users who have gotten errors in production AND who have signed up within a certain time period.
  26. 26. SQL Queries Group by – This statement tells SQL how to group your data when it returns the query result. In this case, data will be grouped by name in the ‗users‘ table. Think of this as a massive sort function in Excel.
  27. 27. SQL Queries Order by – This statement tells SQL how to order your data. This can be useful when pulling massive amounts of information from the database.
  28. 28. SQL Queries Limit – This tells SQL how much data to return. In our case, we‘ll only receive the first 15 results that fit the results of this query.
  29. 29. SQL Queries Functions • Avg() – returns the average value
  30. 30. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows
  31. 31. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows • First() – returns the first value of a column or row
  32. 32. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows • First() – returns the first value of a column or row • Last() – returns the last value
  33. 33. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows • First() – returns the first value of a column or row • Last() – returns the last value • Max() – returns the largest value
  34. 34. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows • First() – returns the first value of a column or row • Last() – returns the last value • Max() – returns the largest value • Min() – returns the smallest value
  35. 35. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows • First() – returns the first value of a column or row • Last() – returns the last value • Max() – returns the largest value • Min() – returns the smallest value • Sum() – returns the sum
  36. 36. You know SQL!
  37. 37. Where to Write Queries? Depends on your stack:
  38. 38. Where to Write Queries? Depends on your stack: • phpMyAdmin
  39. 39. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips
  40. 40. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips
  41. 41. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips • Eclipse SQL Explorer
  42. 42. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips • Eclipse SQL Explorer • SQuirreL
  43. 43. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips • Eclipse SQL Explorer • SQuirreL • Oracle SQL Developer
  44. 44. Finding Table and Column Names Connect to the database: • mysql [-u username] [-h hostname] database-name List all databases (type into MySQL prompt): • show databases Choose the database you want: • use <database-name> List all tables in the database: • show tables Describe a table: • describe <table-name>
  45. 45. Example: Finding repeat buyers Test SQL Database - http://www.w3schools.com/sql/trysql.asp?file name=trysql_select_all STOP How would you construct this query? Try writing it in on your own now.
  46. 46. Example: Finding repeat buyers
  47. 47. Understand Your User Demographics Let‘s say you want to answer the question ―what countries are most of my users from?‖ Write a query that pulls that information from the test W3schools database.
  48. 48. Answer: Understand Your User Demographics
  49. 49. Cohort Analysis See how groups of customers use your product
  50. 50. Cohort Analysis Cohort analysis leads to interesting, actionable data like the below
  51. 51. Closing That‘s it! Get the SQL creator spreadsheet, downloadable queries and additional resources at justinmares.com/sql

Editor's Notes

  • Matt title suggestion – “Know everything about your customers: SQL For Marketers and Growth Hackers”
  • Let’s get through the boring stuff quickly! SQL is a database language designed to allow humans to query, manipulate and communicate with your database (what holds every bit of information about your product, customers and how they use your application). This database language – SQL – is incredibly powerful. It allows anyone who knows it to pull exact, specific data right from your database: the same place all other analytics tools are getting data from. Quickly explain what’s actually happening when you write an SQL statementMost internet startups and companies use MySQL, an open source database that SQL works with. A small group of other companies are using NoSQL databases, but we won’t cover those in this course.There are some other kinds of databases – Redis, mongo, memcache and the like – that we won’t get to in this course. Just know that SQL is by FAR the most common, and the most useful. For others, syntax is similar but not exactly the same
  • Oh, and you’ll make more moneySet the stage with common problems marketers ask. Say “can you answer these basic questions right now?”Script around common problems marketers want to answer. Who are my most valuable customers? Where did they come from? What’s my churn/LTV? Is it getting better or getting worse?
  • You have a question about your users. How much money have customers from the latest ad campaign spent on your product?Without SQL….You bug your development team for days, possibly weeks, to run a simple query that isn’t related to anything they’re working on, and (in their minds) isn’t that importantYou hack together an answer using a dashboard, admin panel and other tools like Google Analytics, Kissmetrics, and the like. It takes a long time and involves a lot of manual data entry. Plus, these kinds of integrations require HOURS of development timeTalk about how I had to wait weeks for devs to run a simple query that took them 10 minutes to see our top customers. Give example of improper filtering I did in Kissmetrics that led to incorrect assumptions and campaigns. BE SPECIFIC
  • With SQL, you have a question about your customers, campaigns or churn and you can answer it. No asking developers or product managers. Simply dig in, answer questions yourself and accept raises and praises as they come in from your boss and coworkers.Lots of new marketing managers and product marketing hires have “SQL Knowledge a huge plus”. This is a huge job hack, and immediately makes you 2x as effective
  • Set the stage with common problems marketers ask. Say “can you answer these basic questions right now?”Script around common problems marketers want to answer. Who are my most valuable customers? Where did they come from? What’s my churn/LTV? Is it getting better or getting worse?
  • Set the stage with common problems marketers ask. Say “can you answer these basic questions right now?”Script around common problems marketers want to answer. Who are my most valuable customers? Where did they come from? What’s my churn/LTV? Is it getting better or getting worse?
  • Set the stage with common problems marketers ask. Say “can you answer these basic questions right now?”Script around common problems marketers want to answer. Who are my most valuable customers? Where did they come from? What’s my churn/LTV? Is it getting better or getting worse?
  • Set the stage with common problems marketers ask. Say “can you answer these basic questions right now?”Script around common problems marketers want to answer. Who are my most valuable customers? Where did they come from? What’s my churn/LTV? Is it getting better or getting worse?
  • Set the stage with common problems marketers ask. Say “can you answer these basic questions right now?”Script around common problems marketers want to answer. Who are my most valuable customers? Where did they come from? What’s my churn/LTV? Is it getting better or getting worse?
  • Imagine not having to mess with Google Analytics, Excel dumps or bothering a developer to answer these key questions.Knowing this information gives you superpowers. It allows you to – in a matter of minutes – get answers to hard questions that you, as a marketer, and your company must know.Then, you can use your answers to inform and decide on your next brilliant marketing strategy.
  • I ran growth at SaaS company Airbrake before our acquisition by Rackspace. Like all companies, we wanted to improve our churn but first needed to learn more about why our customers were cancelling their accounts. Was it because they hated the product, couldn’t figure it out, or were struggling at one specific step? We also wanted to know the type of customers that were cancelling. Were they newer customers? Older customers? Was our churn getting better or worse?Airbrake is an error-tracking tool for developers, so customers who get value from the product use us to capture their errors. I had a hypothesis – were customers who cancelled not going through the process of setting up the tool so that they captured their errors? I decided to find out. I first ran the above query to see how many errors in production each user had generated. Then, compared the number of errors from cancelled accounts to the number of errors from our best customers (data I got using another SQL query!) to look at the difference. It was huge. It turns out, generating an error as an Airbrake user is a key metric – customers that generate errors are much, much more likely to remain happy customers than those that don’t. So, we fixed some things in our onboarding process and cut our churn by more than 40%. This was a huge win for a few hours of data analysis, and one day of implementing a few changes to get people generating errors!Don’t worry, all of these pre-built queries will be given to you later in the course for you to modify and run on your own. Just a quick note as we start, we’ll be using MySQL syntax for this course
  • I want you to have the same big win by the end of this course. First, decide what key metric you’d like to learn more about or improve in your business. Maybe it’s seeing who your best customers are, learning where most of your new signups are coming from, or decreasing your churn. Decide what metric you want to learn more about with SQL, and then do the above steps. Let’s take a second and have you do 2 things to get the most from this course.1. Email your developer and ask him or her to give you read-only access to your database, or to set up a ‘slave’ server that you can run queries against. 2. Ask your developer to show you quickly how to run queries against this database. You’re likely using HerokuDataclips, phpMyAdmin or some other relatively standard database management tool. Be sure to ask if you’re using SQLite3, PostgreSQL, MySQL or some other type of SQL engine.Really. Take 5 minutes to have someone on your team set this up for you. If you’re on your own, check out the links in the resources on how to set up HerokuDataclips or phpMyAdmin, two of the more popular solutions out there.Resourceshttp://sixrevisions.com/tools/top-five-best-database-management-tools/http://www.sqlmaestro.com/products/mysql/http://www.sqlmaestro.com/products/postgresql/http://www.sqlmaestro.com/products/sqlite/https://devcenter.heroku.com/articles/dataclips (only if you’re using Heroku)SQL database to test statements and play around with so you can see how things work together - http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
  • I want you to have the same big win by the end of this course. First, decide what key metric you’d like to learn more about or improve in your business. Maybe it’s seeing who your best customers are, learning where most of your new signups are coming from, or decreasing your churn. Decide what metric you want to learn more about with SQL, and then do the above steps. Let’s take a second and have you do 2 things to get the most from this course.1. Email your developer and ask him or her to give you read-only access to your database, or to set up a ‘slave’ server that you can run queries against. 2. Ask your developer to show you quickly how to run queries against this database. You’re likely using HerokuDataclips, phpMyAdmin or some other relatively standard database management tool. Be sure to ask if you’re using SQLite3, PostgreSQL, MySQL or some other type of SQL engine.Really. Take 5 minutes to have someone on your team set this up for you. If you’re on your own, check out the links in the resources on how to set up HerokuDataclips or phpMyAdmin, two of the more popular solutions out there.Resourceshttp://sixrevisions.com/tools/top-five-best-database-management-tools/http://www.sqlmaestro.com/products/mysql/http://www.sqlmaestro.com/products/postgresql/http://www.sqlmaestro.com/products/sqlite/https://devcenter.heroku.com/articles/dataclips (only if you’re using Heroku)SQL database to test statements and play around with so you can see how things work together - http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
  • Some SQL queries can take a long time to run. And, if you don’t have much experience, that can slow the performance of your actual app or product.
  • We now know that SQL is a language that allows us to pull information from a database. But how does a database work?Check out the example database table from W3schools. A database consists of multiple tables, just like an Excel file can consist of multiple spreadsheets. Each of these tables contains columns and rows with unique customer information you can use to look things up.
  • Easier to query – can filter, sort information and do it all automaticallyVisualize – can automatically update queries and data using different design librariesCan dump SQL into Excel if you want
  • Walk through what this query is doingnote some database systems require ending each statement with a semicolon ;
  • Walk through what this query is doingnote some database systems require ending each statement with a semicolon ;
  • There’s a lot you can do with SQL. In this course, we’ll only cover how you can extract data from a database using the language. As you saw on the last slide, databases are a lot like Excel sheets. What we’ll do with our SQL queries is simply write them in a way that tells SQL what data to select and show us, where to access that data, and how to display it. Can also use “Select Distinct” to pull only unique values from your database. The query above will pull in every user from that time period. If someone signed up 2x, they’d show up 2x. Not so with ‘Distinct’
  • Mention that I’ll cover “count” statement later
  • This one needs some more explaining.http://www.tizag.com/sqlTutorial/sqljoin.phpRight join – will list every row that exists on the right sideLeft join – same but lists every row on the left side of the table. In general these are a bit complex, often not necessary
  • Explain what stack is.
  • Explain what stack is.
  • Explain what stack is.
  • Explain what stack is.
  • Explain what stack is. All these are tools that will make it easier for you to get data from a SQL database
  • Explain what stack is. All these are tools that will make it easier for you to get data from a SQL database
  • Explain what stack is. All these are tools that will make it easier for you to get data from a SQL database
  • Use this information to write your queries. Remember, you have to name the tables and columns you want to pull data from.Show – displays all databases or tables (depending on your selection)Use – tells SQL which database you want to use to run queries onDescribe – describes column data
  • For this part, we’re going to show you how to construct some basic SQL queries using the test SQL database from W3 school. Though these examples will be more fitting for an ecommerce store, you should get a good idea of how to construct these queries by scratch, and you’ll be able to see the output they generate. In real life, you’ll be able to query your database for whatever parameters you want, then dump that data into an Excel or other spreadsheet for easy, non-programattic analysis.First, let’s look at how you can find customers who’ve made repeat purchases at your ecommerce store. Write a query that shows the repeat buyers and how much they ordered in the test SQL database
  • SQL is especially useful for cohort analysisA cohort analysis is a method of analyzing a metric by comparing its behavior between different groups – also known as cohorts – of users. These are generally based on the dates that a user started using a service or application.This kind of data allows you to see if you’re attracting users with higher LTVs, measure the efficacy of marketing campaigns over time, and see how retention compares between different cohortsIn this case, we’re looking at all users who generated an error in the month of March, 2014. Then, we can compare this to other groups of users from previous months to see if new users are sending more errors (aka using the product more)
  • This graph is showing how different marketing campaigns lead to orders months after the customer has been acquired. As you can see in this example from Chartio, Facebook ads lead to orders throughout the customer lifecycle, while customers acquired via TV advertising don’t place any more orders after 4 months. All of this data is exceedingly useful in planning your next marketing campaigns.

×