SlideShare una empresa de Scribd logo
1 de 52
SQL for Marketers and Growth
Hackers
Everything you need to know about using
SQL for analytics, marketing and growth
hacking
What is SQL?
SQL is simply a language that makes it easy
to pull data from your application‘s database.
What can you do with SQL?
Answer questions!
Life without SQL
Without SQL….
• You 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 proficiency, 50% of
new marketing hires will have technical
backgrounds.”
- quote from IDC research of CMOs
Why is SQL important to me?
SQL will help you see, understand and
improve your company‘s metrics.
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.)
Do you know the answers to some very basic
questions about your business?
Take a Minute
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
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
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
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
What can you do with SQL?
• Make data-driven decisions
• Run profitable campaigns using data
• Understand every metric in your business
• Get superpowers
How we improved churn with the
help of SQL
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
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
A WORD OF CAUTION
Only run queries on a read-only or
“slave” database
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
Why SQL is Better than Excel
• Auto-updating information
• Easier to query
• Can visualize data automatically
Example Query
*See how this query works by checking out the example database I pulled together
at - http://bitly.com/udemysql
Example Query
*See how this query works by checking out the example database I pulled together
at - http://bitly.com/udemysql
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.
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.
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.
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.
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.
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.
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.
SQL Queries
Functions
• Avg() – returns the average value
SQL Queries
Functions
• Avg() – returns the average value
• Count() – returns the number of rows
SQL Queries
Functions
• Avg() – returns the average value
• Count() – returns the number of rows
• First() – returns the first value of a column
or row
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
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
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
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
You know SQL!
Where to Write Queries?
Depends on your stack:
Where to Write Queries?
Depends on your stack:
• phpMyAdmin
Where to Write Queries?
Depends on your stack:
• phpMyAdmin
• Heroku Postgres Dataclips
Where to Write Queries?
Depends on your stack:
• phpMyAdmin
• Heroku Postgres Dataclips
Where to Write Queries?
Depends on your stack:
• phpMyAdmin
• Heroku Postgres Dataclips
• Eclipse SQL Explorer
Where to Write Queries?
Depends on your stack:
• phpMyAdmin
• Heroku Postgres Dataclips
• Eclipse SQL Explorer
• SQuirreL
Where to Write Queries?
Depends on your stack:
• phpMyAdmin
• Heroku Postgres Dataclips
• Eclipse SQL Explorer
• SQuirreL
• Oracle SQL Developer
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>
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.
Example: Finding repeat buyers
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.
Answer: Understand Your User
Demographics
Cohort Analysis
See how groups of customers use your
product
Cohort Analysis
Cohort analysis leads to interesting,
actionable data like the below
Closing
That‘s it!
Get the SQL creator spreadsheet,
downloadable queries and additional
resources at
justinmares.com/sql

Más contenido relacionado

Destacado

How to Plug a Leaky Sales Funnel With Facebook Retargeting
How to Plug a Leaky Sales Funnel With Facebook RetargetingHow to Plug a Leaky Sales Funnel With Facebook Retargeting
How to Plug a Leaky Sales Funnel With Facebook RetargetingDigital Marketer
 
Optimize Your Sales & Marketing Funnel
Optimize Your Sales & Marketing FunnelOptimize Your Sales & Marketing Funnel
Optimize Your Sales & Marketing FunnelHubSpot
 
LinkedIn Ads Platform Master Class
LinkedIn Ads Platform Master ClassLinkedIn Ads Platform Master Class
LinkedIn Ads Platform Master ClassLinkedIn
 
Wireframes - a brief overview
Wireframes - a brief overviewWireframes - a brief overview
Wireframes - a brief overviewJenni Leder
 
Understand A/B Testing in 9 use cases & 7 mistakes
Understand A/B Testing in 9 use cases & 7 mistakesUnderstand A/B Testing in 9 use cases & 7 mistakes
Understand A/B Testing in 9 use cases & 7 mistakesTheFamily
 
No excuses user research
No excuses user researchNo excuses user research
No excuses user researchLily Dart
 
How Top Brands Use Referral Programs to Drive Customer Acquisition
How Top Brands Use Referral Programs to Drive Customer AcquisitionHow Top Brands Use Referral Programs to Drive Customer Acquisition
How Top Brands Use Referral Programs to Drive Customer AcquisitionKissmetrics on SlideShare
 
10 Ways You're Using AdWords Wrong and How to Correct Those Practices
10 Ways You're Using AdWords Wrong and How to Correct Those Practices 10 Ways You're Using AdWords Wrong and How to Correct Those Practices
10 Ways You're Using AdWords Wrong and How to Correct Those Practices Kissmetrics on SlideShare
 
Google Analytics Fundamentals: Set Up and Basics for Measurement
Google Analytics Fundamentals: Set Up and Basics for MeasurementGoogle Analytics Fundamentals: Set Up and Basics for Measurement
Google Analytics Fundamentals: Set Up and Basics for MeasurementOrbit Media Studios
 
Biz Dev 101 - An Interactive Workshop on How Deals Get Done
Biz Dev 101 - An Interactive Workshop on How Deals Get DoneBiz Dev 101 - An Interactive Workshop on How Deals Get Done
Biz Dev 101 - An Interactive Workshop on How Deals Get DoneScott Pollack
 
A Guide to User Research (for People Who Don't Like Talking to Other People)
A Guide to User Research (for People Who Don't Like Talking to Other People)A Guide to User Research (for People Who Don't Like Talking to Other People)
A Guide to User Research (for People Who Don't Like Talking to Other People)Stephanie Wills
 
The Essentials of Community Building by Mack Fogelson
The Essentials of Community Building by Mack FogelsonThe Essentials of Community Building by Mack Fogelson
The Essentials of Community Building by Mack FogelsonMackenzie Fogelson
 
Stop Leaving Money on the Table! Optimizing your Site for Users and Revenue
Stop Leaving Money on the Table! Optimizing your Site for Users and RevenueStop Leaving Money on the Table! Optimizing your Site for Users and Revenue
Stop Leaving Money on the Table! Optimizing your Site for Users and RevenueJosh Patrice
 
10 Mobile Marketing Campaigns That Went Viral and Made Millions
10 Mobile Marketing Campaigns That Went Viral and Made Millions10 Mobile Marketing Campaigns That Went Viral and Made Millions
10 Mobile Marketing Campaigns That Went Viral and Made MillionsMark Fidelman
 
Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...
Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...
Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...GeekWire
 
Using Your Growth Model to Drive Smarter High Tempo Testing
Using Your Growth Model to Drive Smarter High Tempo TestingUsing Your Growth Model to Drive Smarter High Tempo Testing
Using Your Growth Model to Drive Smarter High Tempo TestingSean Ellis
 
User experience doesn't happen on a screen: It happens in the mind.
User experience doesn't happen on a screen: It happens in the mind.User experience doesn't happen on a screen: It happens in the mind.
User experience doesn't happen on a screen: It happens in the mind.John Whalen
 

Destacado (20)

How to Plug a Leaky Sales Funnel With Facebook Retargeting
How to Plug a Leaky Sales Funnel With Facebook RetargetingHow to Plug a Leaky Sales Funnel With Facebook Retargeting
How to Plug a Leaky Sales Funnel With Facebook Retargeting
 
Optimize Your Sales & Marketing Funnel
Optimize Your Sales & Marketing FunnelOptimize Your Sales & Marketing Funnel
Optimize Your Sales & Marketing Funnel
 
LinkedIn Ads Platform Master Class
LinkedIn Ads Platform Master ClassLinkedIn Ads Platform Master Class
LinkedIn Ads Platform Master Class
 
Wireframes - a brief overview
Wireframes - a brief overviewWireframes - a brief overview
Wireframes - a brief overview
 
Understand A/B Testing in 9 use cases & 7 mistakes
Understand A/B Testing in 9 use cases & 7 mistakesUnderstand A/B Testing in 9 use cases & 7 mistakes
Understand A/B Testing in 9 use cases & 7 mistakes
 
No excuses user research
No excuses user researchNo excuses user research
No excuses user research
 
HTML & CSS Masterclass
HTML & CSS MasterclassHTML & CSS Masterclass
HTML & CSS Masterclass
 
How Top Brands Use Referral Programs to Drive Customer Acquisition
How Top Brands Use Referral Programs to Drive Customer AcquisitionHow Top Brands Use Referral Programs to Drive Customer Acquisition
How Top Brands Use Referral Programs to Drive Customer Acquisition
 
10 Ways You're Using AdWords Wrong and How to Correct Those Practices
10 Ways You're Using AdWords Wrong and How to Correct Those Practices 10 Ways You're Using AdWords Wrong and How to Correct Those Practices
10 Ways You're Using AdWords Wrong and How to Correct Those Practices
 
Intro to Mixpanel
Intro to MixpanelIntro to Mixpanel
Intro to Mixpanel
 
Google Analytics Fundamentals: Set Up and Basics for Measurement
Google Analytics Fundamentals: Set Up and Basics for MeasurementGoogle Analytics Fundamentals: Set Up and Basics for Measurement
Google Analytics Fundamentals: Set Up and Basics for Measurement
 
Biz Dev 101 - An Interactive Workshop on How Deals Get Done
Biz Dev 101 - An Interactive Workshop on How Deals Get DoneBiz Dev 101 - An Interactive Workshop on How Deals Get Done
Biz Dev 101 - An Interactive Workshop on How Deals Get Done
 
Intro to Facebook Ads
Intro to Facebook AdsIntro to Facebook Ads
Intro to Facebook Ads
 
A Guide to User Research (for People Who Don't Like Talking to Other People)
A Guide to User Research (for People Who Don't Like Talking to Other People)A Guide to User Research (for People Who Don't Like Talking to Other People)
A Guide to User Research (for People Who Don't Like Talking to Other People)
 
The Essentials of Community Building by Mack Fogelson
The Essentials of Community Building by Mack FogelsonThe Essentials of Community Building by Mack Fogelson
The Essentials of Community Building by Mack Fogelson
 
Stop Leaving Money on the Table! Optimizing your Site for Users and Revenue
Stop Leaving Money on the Table! Optimizing your Site for Users and RevenueStop Leaving Money on the Table! Optimizing your Site for Users and Revenue
Stop Leaving Money on the Table! Optimizing your Site for Users and Revenue
 
10 Mobile Marketing Campaigns That Went Viral and Made Millions
10 Mobile Marketing Campaigns That Went Viral and Made Millions10 Mobile Marketing Campaigns That Went Viral and Made Millions
10 Mobile Marketing Campaigns That Went Viral and Made Millions
 
Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...
Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...
Brenda Spoonemore - A biz dev playbook for startups: Why, when and how to do ...
 
Using Your Growth Model to Drive Smarter High Tempo Testing
Using Your Growth Model to Drive Smarter High Tempo TestingUsing Your Growth Model to Drive Smarter High Tempo Testing
Using Your Growth Model to Drive Smarter High Tempo Testing
 
User experience doesn't happen on a screen: It happens in the mind.
User experience doesn't happen on a screen: It happens in the mind.User experience doesn't happen on a screen: It happens in the mind.
User experience doesn't happen on a screen: It happens in the mind.
 

Similar a SQL Tutorial for Marketers

What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really DoingDave Stokes
 
QuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solutionQuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solutionRTTS
 
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...RTTS
 
Real World Performance - OLTP
Real World Performance - OLTPReal World Performance - OLTP
Real World Performance - OLTPConnor McDonald
 
ML Meetup #27 - Data Infrasctructure and Data Access in Nubank
ML Meetup #27 - Data Infrasctructure and Data Access in NubankML Meetup #27 - Data Infrasctructure and Data Access in Nubank
ML Meetup #27 - Data Infrasctructure and Data Access in NubankLuis Moneda
 
Query Wizards - data testing made easy - no programming
Query Wizards - data testing made easy - no programmingQuery Wizards - data testing made easy - no programming
Query Wizards - data testing made easy - no programmingRTTS
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server DatabasesColdFusionConference
 
Sql interview question part 8
Sql interview question part 8Sql interview question part 8
Sql interview question part 8kaashiv1
 
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon ConsultingSolr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon ConsultingLucidworks
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptxKareemBullard1
 
Solr JDBC - Lucene/Solr Revolution 2016
Solr JDBC - Lucene/Solr Revolution 2016Solr JDBC - Lucene/Solr Revolution 2016
Solr JDBC - Lucene/Solr Revolution 2016Kevin Risden
 
Big Data Testing: Ensuring MongoDB Data Quality
Big Data Testing: Ensuring MongoDB Data QualityBig Data Testing: Ensuring MongoDB Data Quality
Big Data Testing: Ensuring MongoDB Data QualityRTTS
 

Similar a SQL Tutorial for Marketers (20)

What Your Database Query is Really Doing
What Your Database Query is Really DoingWhat Your Database Query is Really Doing
What Your Database Query is Really Doing
 
QuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solutionQuerySurge - the automated Data Testing solution
QuerySurge - the automated Data Testing solution
 
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
Big Data Testing : Automate theTesting of Hadoop, NoSQL & DWH without Writing...
 
Real World Performance - OLTP
Real World Performance - OLTPReal World Performance - OLTP
Real World Performance - OLTP
 
ML Meetup #27 - Data Infrasctructure and Data Access in Nubank
ML Meetup #27 - Data Infrasctructure and Data Access in NubankML Meetup #27 - Data Infrasctructure and Data Access in Nubank
ML Meetup #27 - Data Infrasctructure and Data Access in Nubank
 
Query Wizards - data testing made easy - no programming
Query Wizards - data testing made easy - no programmingQuery Wizards - data testing made easy - no programming
Query Wizards - data testing made easy - no programming
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 
Breaking data
Breaking dataBreaking data
Breaking data
 
Building better SQL Server Databases
Building better SQL Server DatabasesBuilding better SQL Server Databases
Building better SQL Server Databases
 
Sql interview question part 8
Sql interview question part 8Sql interview question part 8
Sql interview question part 8
 
Ebook8
Ebook8Ebook8
Ebook8
 
Collab365 Empower-Your-Applications-With-Azure-Machine-Learning
Collab365 Empower-Your-Applications-With-Azure-Machine-LearningCollab365 Empower-Your-Applications-With-Azure-Machine-Learning
Collab365 Empower-Your-Applications-With-Azure-Machine-Learning
 
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon ConsultingSolr JDBC: Presented by Kevin Risden, Avalon Consulting
Solr JDBC: Presented by Kevin Risden, Avalon Consulting
 
Pycon Talk
Pycon TalkPycon Talk
Pycon Talk
 
05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx05_DP_300T00A_Optimize.pptx
05_DP_300T00A_Optimize.pptx
 
Solr JDBC - Lucene/Solr Revolution 2016
Solr JDBC - Lucene/Solr Revolution 2016Solr JDBC - Lucene/Solr Revolution 2016
Solr JDBC - Lucene/Solr Revolution 2016
 
Big Data Testing: Ensuring MongoDB Data Quality
Big Data Testing: Ensuring MongoDB Data QualityBig Data Testing: Ensuring MongoDB Data Quality
Big Data Testing: Ensuring MongoDB Data Quality
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 

Último

wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...KarteekMane1
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataTecnoIncentive
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxTasha Penwell
 
convolutional neural network and its applications.pdf
convolutional neural network and its applications.pdfconvolutional neural network and its applications.pdf
convolutional neural network and its applications.pdfSubhamKumar3239
 
Digital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksDigital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksdeepakthakur548787
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...Milind Agarwal
 
Principles and Practices of Data Visualization
Principles and Practices of Data VisualizationPrinciples and Practices of Data Visualization
Principles and Practices of Data VisualizationKianJazayeri1
 
INTRODUCTION TO Natural language processing
INTRODUCTION TO Natural language processingINTRODUCTION TO Natural language processing
INTRODUCTION TO Natural language processingsocarem879
 
SMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptxSMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptxHaritikaChhatwal1
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Thomas Poetter
 
Networking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxNetworking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxHimangsuNath
 
What To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxWhat To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxSimranPal17
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 

Último (20)

wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded data
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptxThe Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
The Power of Data-Driven Storytelling_ Unveiling the Layers of Insight.pptx
 
convolutional neural network and its applications.pdf
convolutional neural network and its applications.pdfconvolutional neural network and its applications.pdf
convolutional neural network and its applications.pdf
 
Digital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksDigital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing works
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
Unveiling the Role of Social Media Suspect Investigators in Preventing Online...
 
Principles and Practices of Data Visualization
Principles and Practices of Data VisualizationPrinciples and Practices of Data Visualization
Principles and Practices of Data Visualization
 
INTRODUCTION TO Natural language processing
INTRODUCTION TO Natural language processingINTRODUCTION TO Natural language processing
INTRODUCTION TO Natural language processing
 
SMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptxSMOTE and K-Fold Cross Validation-Presentation.pptx
SMOTE and K-Fold Cross Validation-Presentation.pptx
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
 
Networking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxNetworking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptx
 
What To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxWhat To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptx
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 

SQL Tutorial for Marketers

  • 1.
  • 2. SQL for Marketers and Growth Hackers Everything you need to know about using SQL for analytics, marketing and growth hacking
  • 3. What is SQL? SQL is simply a language that makes it easy to pull data from your application‘s database.
  • 4. What can you do with SQL? Answer questions!
  • 5. Life without SQL Without SQL…. • You annoy technical people on your team • Hack together rough approximations for hours
  • 6. 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
  • 7. Why is SQL important to me? SQL will help you see, understand and improve your company‘s metrics.
  • 8. 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.)
  • 9. Do you know the answers to some very basic questions about your business? Take a Minute
  • 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? Take a Minute
  • 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? Take a Minute
  • 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? Take a Minute
  • 13. 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
  • 14. What can you do with SQL? • Make data-driven decisions • Run profitable campaigns using data • Understand every metric in your business • Get superpowers
  • 15. How we improved churn with the help of SQL
  • 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
  • 17. 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
  • 18. A WORD OF CAUTION Only run queries on a read-only or “slave” database
  • 19. 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
  • 20. Why SQL is Better than Excel • Auto-updating information • Easier to query • Can visualize data automatically
  • 21. Example Query *See how this query works by checking out the example database I pulled together at - http://bitly.com/udemysql
  • 22. Example Query *See how this query works by checking out the example database I pulled together at - http://bitly.com/udemysql
  • 23. 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.
  • 24. 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.
  • 25. 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.
  • 26. 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.
  • 27. 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.
  • 28. 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.
  • 29. 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.
  • 30. SQL Queries Functions • Avg() – returns the average value
  • 31. SQL Queries Functions • Avg() – returns the average value • Count() – returns the number of rows
  • 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
  • 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
  • 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
  • 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
  • 36. 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
  • 38. Where to Write Queries? Depends on your stack:
  • 39. Where to Write Queries? Depends on your stack: • phpMyAdmin
  • 40. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips
  • 41. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips
  • 42. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips • Eclipse SQL Explorer
  • 43. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips • Eclipse SQL Explorer • SQuirreL
  • 44. Where to Write Queries? Depends on your stack: • phpMyAdmin • Heroku Postgres Dataclips • Eclipse SQL Explorer • SQuirreL • Oracle SQL Developer
  • 45. 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>
  • 46. 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.
  • 48. 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.
  • 49. Answer: Understand Your User Demographics
  • 50. Cohort Analysis See how groups of customers use your product
  • 51. Cohort Analysis Cohort analysis leads to interesting, actionable data like the below
  • 52. Closing That‘s it! Get the SQL creator spreadsheet, downloadable queries and additional resources at justinmares.com/sql

Notas del editor

  1. Matt title suggestion – “Know everything about your customers: SQL For Marketers and Growth Hackers”
  2. 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
  3. 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?
  4. 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
  5. 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
  6. 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?
  7. 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?
  8. 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?
  9. 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?
  10. 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?
  11. 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.
  12. 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
  13. 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
  14. 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
  15. 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.
  16. 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.
  17. 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
  18. Walk through what this query is doingnote some database systems require ending each statement with a semicolon ;
  19. Walk through what this query is doingnote some database systems require ending each statement with a semicolon ;
  20. 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’
  21. Mention that I’ll cover “count” statement later
  22. 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
  23. Explain what stack is.
  24. Explain what stack is.
  25. Explain what stack is.
  26. Explain what stack is.
  27. Explain what stack is. All these are tools that will make it easier for you to get data from a SQL database
  28. Explain what stack is. All these are tools that will make it easier for you to get data from a SQL database
  29. Explain what stack is. All these are tools that will make it easier for you to get data from a SQL database
  30. 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
  31. 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
  32. 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)
  33. 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.