Sei sulla pagina 1di 49

SQL FOR MARKETERS & GROWTH HACKERS

EVERYTHING YOU NEED TO KNOW ABOUT USING SQL


FOR ANALYTICS, MARKETING & GROWTH HACKING
PRESENTED BY JUSTIN MARES
SQL is simply a language
that makes it easy to pull
data from your
applications database
WHAT IS
SQL
Simple Query
Output Data
Internal Operations
User
SQL Interface
Database
WHAT IS
SQL
WHAT CAN YOU DO WITH SQL?
WHAT CAN YOU DO WITH SQL?
ANSWER QUESTIONS!
LIFE WITHOUT
SQL
Annoy technical people
on your team
Hack together rough
approximations for hours
LIFE WITH
SQL
Starting in 2013, after the
CMO realizes that he/she
does not have the skill sets
in place for data analytics
prociency, 50% of new
marketing hires will have
technical backgrounds.
IDC research of CMOs
WHY IS SQL IMPORTANT TO ME?
WHY IS SQL IMPORTANT TO ME?
HELPS YOU SEE, UNDERSTAND, IMPROVE METRICS
WHY IS SQL IMPORTANT TO ME?
HELPS YOU SEE, UNDERSTAND, IMPROVE METRICS
ACCESS DATA OTHER ANALYTICS TOOLS CANT
Choose 1 metric you want to improve for your company,
and lets spend the rest of the course working on SQL
statements to pull data around that metric.
Check out the accompanying spreadsheet to see which
key metrics you should be looking at (depending on
your company type) and how you can use SQL to learn
more about your customers.
Are you getting more or
less customers this
month compared to the
previous?
1
TAKE A MINUTE
DO YOU KNOW THE ANSWERS TO SOME VERY BASIC QUESTIONS ABOUT YOUR BUSINESS?
Are you getting more or
less customers this
month compared to the
previous?
1
What percentage of
customers are active
each week on your
platform?
2
TAKE A MINUTE
DO YOU KNOW THE ANSWERS TO SOME VERY BASIC QUESTIONS ABOUT YOUR BUSINESS?
Are you getting more or
less customers this
month compared to the
previous?
1
What percentage of
customers are active
each week on your
platform?
2
How many users leave
each week (churn)? Is
this trending up or
down?
3
TAKE A MINUTE
DO YOU KNOW THE ANSWERS TO SOME VERY BASIC QUESTIONS ABOUT YOUR BUSINESS?
Are you getting more or
less customers this
month compared to the
previous?
1
What percentage of
customers are active
each week on your
platform?
2
How many users leave
each week (churn)? Is
this trending up or
down?
3
Who are your 100 most
active users? Who are
your 100 most valuable
customers?
4
TAKE A MINUTE
DO YOU KNOW THE ANSWERS TO SOME VERY BASIC QUESTIONS ABOUT YOUR BUSINESS?
WHAT CAN YOU DO WITH SQL?
MAKE DATA-DRIVEN DECISIONS
RUN PROFITABLE CAMPAIGNS USING DATA
UNDERSTAND EVERY METRIC IN YOUR BUSINESS
GET SUPERPOWERS
IMPROVING CHURN WITH
SQL
EARLY WIN FOR YOU!
LETS TAKE A SECOND AND HAVE YOU DO 2 THINGS TO GET THE MOST FROM THIS COURSE:
Get read-only access
to your database
Ask someone technical
how to run queries against
your database
1 2
A WORD OF CAUTION
ONLY RUN QUERIES
ON A READ-ONLY OR
SLAVE DATABASE
Databases work like an Excel
spreadsheet
There are multiple tables
with unique names, which
contain columns & rows
WORKING WITH
SQL
1
2 3
WHY SQL IS BETTER THAN EXCEL
Can automatically
visualize data
Auto-updating
information
Easier to query
EXAMPLE QUERY
See how this query works by checking out the example database I
pulled together at - http://bitly.com/udemysql
QUERIES
SQL
This command tells SQL what
data you want to see. This data
needs to be a part of the table
youre accessing.
SELECT
QUERIES
SQL
FROM
Tells SQL where to pull the data
from. Whats the name of the table
youre using to capture data? Put
that after the from statement.
QUERIES
JOIN
SQL
This command temporarily joins
two tables wed like to search, so
that we can pull data from multiple
queries. Join tells SQL which
table wed like to join, and the on
modier tells SQL which columns
in those tables should map to each
other.
QUERIES
WHERE
SQL
This statement tells SQL how to
access the right data. In this case,
were telling it to show us users
who have gotten errors in
production AND who have signed
up within a certain time period.
QUERIES
GROUP BY
SQL
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.
QUERIES
ORDER BY
SQL
This statement tells SQL how to
order your data. This can be useful
when pulling massive amounts of
information from the database.
QUERIES
LIMIT
SQL
This tells SQL how much data to
return. In our case, well only
receive the rst 15 results that t
the results of this query.
SQL QUERY FUNCTIONS
AVG()
Returns the
average
value
SQL QUERY FUNCTIONS
AVG() COUNT()
Returns the
average
value
Returns the
number of
rows
SQL QUERY FUNCTIONS
AVG() COUNT() FIRST()
Returns the
average
value
Returns the
number of
rows
Returns the
rst value
in a column
or row
SQL QUERY FUNCTIONS
AVG() COUNT() FIRST() LAST()
Returns the
average
value
Returns the
number of
rows
Returns the
rst value
in a column
or row
Returns the
last value
SQL QUERY FUNCTIONS
AVG() COUNT() FIRST() LAST() MAX()
Returns the
average
value
Returns the
number of
rows
Returns the
rst value
in a column
or row
Returns the
last value
Returns the
largest
value
SQL QUERY FUNCTIONS
AVG() COUNT() FIRST() LAST() MAX() MIN()
Returns the
average
value
Returns the
number of
rows
Returns the
rst value
in a column
or row
Returns the
last value
Returns the
largest
value
Returns the
smallest
value
SQL QUERY FUNCTIONS
AVG() COUNT() FIRST() LAST() MAX() MIN() SUM()
Returns the
average
value
Returns the
number of
rows
Returns the
rst value
in a column
or row
Returns the
last value
Returns the
largest
value
Returns the
smallest
value
Returns the
sum of all
values
CONGRATULATIONS
SQL
YOU KNOW
1 2 3 4
WHERE TO WRITE QUERIES?
THAT DEPENDS ON YOUR STACK
5
phpMyAdmin Heroku
Postgress Data
Clips
Eclipse SQL
Explorer
SQuirreL Oracle SQL
Developer
1
FINDING TABLE & COLUMN NAMES
LIST ALL DATABASES
CHOOSE THE DATABASE YOU WANT
LIST ALL TABLES IN THE DATABASE
CONNECT TO DATABASE
DESCRIBE TABLE
!"#$% '() )#*+,-!*. '(/ /0#1,-!*. 2-1-3-#*(,-!*
#/04 2-1-3-#*#
)#* 52-1-3-#*(,-!*6
#/04 1-3%*#
2*#7+83* 51-3%*(,-!*6
EXAMPLE
FINDING REPEAT BUYERS
Test SQL Database
http://www.w3schools.com/sql/trysql.asp?lename=trysql_select_all
STOP
How would you construct this query? Try writing it on your own now.
EXAMPLE
FINDING REPEAT BUYERS
SOLUTION
EXAMPLE
FINDING REPEAT BUYERS
What was the difference in outputs?
What was the result of your query?
If you didnt get the same results, what did you write?
EXAMPLE
UNDERSTANDING YOUR USER DEMOGRAPHICS
Lets say you want to answer the question what countries are most of my
users from?
STOP
Write a query that pulls that information from the test W3schools database.
EXAMPLE
UNDERSTANDING YOUR USER DEMOGRAPHICS
SOLUTION
COHORT ANALYSIS
SEE HOW GROUPS OF CUSTOMERS USE YOUR PRODUCT
Cohort Analysis: Analyzing a metric by comparing its behaviour
between different groups (cohorts) of users
COHORT ANALYSIS
SEE HOW GROUPS OF CUSTOMERS USE YOUR PRODUCT
Cohort Analysis leads to interesting & actionable data, like below:
ADVANCED
TIPS
Scripting
Reporting
FINAL THOUGHTS
Get the SQL creator spreadsheet, downloadable queries
and additional resources at
justinmares.com/sql
FINAL THOUGHTS
SQL is an incredibly powerful tool in any marketers arsenal
Take some time to get access to a slave (or read-only) server, and
start writing queries!

Potrebbero piacerti anche