SlideShare a Scribd company logo
1 of 11
SQL
for Business Problems
PROBLEM
Using a CTE and the subscriptions and products tables to calculate for each product:
• maximum and minimum monthly revenue
• average monthly revenue
• standard deviation of monthly revenue
APPROACH
DESCRIPTIVE STATISTICS WITH CTE
The company is setting 2023 goals and needs insights into the monthly revenue distribution for
Basic and Expert product subscriptions throughout 2022
SOLUTION
OUTPUT
PROBLEM
• Using Window Function to calculate the running total of sales revenue, running_total,
and the % of quota reached, percent_quota, for each sales employee Using the sales
and employees table.
• cast() to convert the numerator a float
APPROACH
TRACKING RUNNING TOTALS WITH WINDOW FUNCTIONS
The sales team is committed to achieving product sales, with set quotas that determine their
commission earnings. Given the direct correlation between these goals and revenue, the team
manager aims to monitor the performance of each sales member consistently over the course of
the year.
SOLUTION
OUTPUT
PROBLEM
As users can go through statuses (fig1) we will use two CTEs and
three tables:
• Generate a CTE to compute the maxstatus reached for each
subscriptionid within the paymentstatuslog table.
• Next, form a CTE by combining the subscriptions table with the
previously created CTE. This enables the utilization of the
provided paymentfunnelstage code to classify each
subscriptionid based on its maxstatus and currentstatus.
• In a separate select statement below, count the number of
subscriptionid per paymentfunnelstage .
APPROACH
PAYMENT FUNNEL ANALYSIS WITH
CTE
The product manager requested a payment funnel analysis from the analytics team to identify
where users drop out in the payment process and gain full visibility into each stage from the
user's perspective
fig1
SOLUTION
OUTPUT
PROBLEM
• Using UNION and the cancelations table, calculate the percent of canceled
subscriptions that reported 'Expensive' as one of their cancelation reasons.
• Create cancel CTE
• Calculate the percent of canceled subscriptions that reported 'Expensive' as one of
their cancelation reasons. percent_expensive
APPROACH
UNPIVOTING COLUMNS INTO ROWS USING
UNION
Considering the challenging economic conditions, the initial focus is on extracting the percentage
of canceled subscriptions attributed to the product being deemed too expensive. People have the
option to choose up to three reasons from a predefined list. It's not possible for users to pick the
same reason more than once, and some users may choose fewer than three reasons, resulting in
null values for certain cancellation reason columns.
SOLUTION
OUTPUT
PROBLEM
Using a CTE and the frontendeventlog table to know how many users clicked the email
link :
• Count the number of users, num_users , in each num_link_clicks category
• Filter by eventid = 5, as it’s accessed when the user reaches a unique landing page
from this campaign email.
APPROACH
EXPLORING VARIABLE DISTRIBUTIONS
WITH CTE
The marketing team manager inquires about the effectiveness of the recent email campaign.
After the campaign launch, they are interested in obtaining information about the number of
users who clicked the link in the email.
SOLUTION
OUTPUT

More Related Content

Similar to SQL for Business Problems.pptx

Reconnect 17 Configuring the Cost Balancing Work Center
Reconnect 17 Configuring the Cost Balancing Work CenterReconnect 17 Configuring the Cost Balancing Work Center
Reconnect 17 Configuring the Cost Balancing Work CenterSmart ERP Solutions, Inc.
 
E billing and invoice system
E billing and invoice systemE billing and invoice system
E billing and invoice systemSurya Indira
 
What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...
What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...
What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...Smarten Augmented Analytics
 
Customer_Churn_prediction.pptx
Customer_Churn_prediction.pptxCustomer_Churn_prediction.pptx
Customer_Churn_prediction.pptxAniket Patil
 
Customer_Churn_prediction.pptx
Customer_Churn_prediction.pptxCustomer_Churn_prediction.pptx
Customer_Churn_prediction.pptxpatilaniket2418
 
Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...Sami JAMMALI
 
Sage 300 ERP (Accpac) Year-End Closing
Sage 300 ERP (Accpac) Year-End ClosingSage 300 ERP (Accpac) Year-End Closing
Sage 300 ERP (Accpac) Year-End ClosingNet at Work
 
goalseekandsensitivityanalysis-221112123352-9fe0067e.pptx
goalseekandsensitivityanalysis-221112123352-9fe0067e.pptxgoalseekandsensitivityanalysis-221112123352-9fe0067e.pptx
goalseekandsensitivityanalysis-221112123352-9fe0067e.pptxIrfanRashid36
 
OpenERP Functional Memento
OpenERP Functional MementoOpenERP Functional Memento
OpenERP Functional MementoOdoo
 
Building a Scorecard
Building a ScorecardBuilding a Scorecard
Building a ScorecardMatt Hansen
 
CUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9i
CUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9iCUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9i
CUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9iAkash Gupta
 
Customer Success Plan Template
Customer Success Plan TemplateCustomer Success Plan Template
Customer Success Plan TemplateOpsPanda
 
Finit formula and business rule efficiency in one stream
Finit   formula and business rule efficiency in one streamFinit   formula and business rule efficiency in one stream
Finit formula and business rule efficiency in one streamfinitsolutions
 
Final report_Raymond
Final report_RaymondFinal report_Raymond
Final report_RaymondAkash Indani
 
Hansen aise im ch07
Hansen aise im ch07Hansen aise im ch07
Hansen aise im ch07Daeng Aiman
 
1. customer master records
1. customer master records1. customer master records
1. customer master recordsSam Raju
 
Comp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codeComp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codepradesigali1
 

Similar to SQL for Business Problems.pptx (20)

Reconnect 17 Configuring the Cost Balancing Work Center
Reconnect 17 Configuring the Cost Balancing Work CenterReconnect 17 Configuring the Cost Balancing Work Center
Reconnect 17 Configuring the Cost Balancing Work Center
 
E billing and invoice system
E billing and invoice systemE billing and invoice system
E billing and invoice system
 
What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...
What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...
What Is Multilayer Perceptron Classifier And How Is It Used For Enterprise An...
 
Customer_Churn_prediction.pptx
Customer_Churn_prediction.pptxCustomer_Churn_prediction.pptx
Customer_Churn_prediction.pptx
 
Customer_Churn_prediction.pptx
Customer_Churn_prediction.pptxCustomer_Churn_prediction.pptx
Customer_Churn_prediction.pptx
 
Clicks vs code df14pptx
Clicks vs code df14pptxClicks vs code df14pptx
Clicks vs code df14pptx
 
Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
Mr20 enus 01-Report Design in Management Reporter 2.0 for Microsoft Dynamics®...
 
Sage 300 ERP (Accpac) Year-End Closing
Sage 300 ERP (Accpac) Year-End ClosingSage 300 ERP (Accpac) Year-End Closing
Sage 300 ERP (Accpac) Year-End Closing
 
Ap daily procdure
Ap daily procdureAp daily procdure
Ap daily procdure
 
goalseekandsensitivityanalysis-221112123352-9fe0067e.pptx
goalseekandsensitivityanalysis-221112123352-9fe0067e.pptxgoalseekandsensitivityanalysis-221112123352-9fe0067e.pptx
goalseekandsensitivityanalysis-221112123352-9fe0067e.pptx
 
OpenERP Functional Memento
OpenERP Functional MementoOpenERP Functional Memento
OpenERP Functional Memento
 
Building a Scorecard
Building a ScorecardBuilding a Scorecard
Building a Scorecard
 
CUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9i
CUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9iCUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9i
CUSTOMER CARE ADMINISTRATION-developer-2000 and oracle 9i
 
Customer Success Plan Template
Customer Success Plan TemplateCustomer Success Plan Template
Customer Success Plan Template
 
Finit formula and business rule efficiency in one stream
Finit   formula and business rule efficiency in one streamFinit   formula and business rule efficiency in one stream
Finit formula and business rule efficiency in one stream
 
Final report_Raymond
Final report_RaymondFinal report_Raymond
Final report_Raymond
 
Budgeting
BudgetingBudgeting
Budgeting
 
Hansen aise im ch07
Hansen aise im ch07Hansen aise im ch07
Hansen aise im ch07
 
1. customer master records
1. customer master records1. customer master records
1. customer master records
 
Comp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source codeComp 220 i lab 3 bank account lab report and source code
Comp 220 i lab 3 bank account lab report and source code
 

More from Mustafa Ahmed

Power BI Dashboard.pptx
Power BI Dashboard.pptxPower BI Dashboard.pptx
Power BI Dashboard.pptxMustafa Ahmed
 
Clash Detection Dashboard.pptx
Clash Detection Dashboard.pptxClash Detection Dashboard.pptx
Clash Detection Dashboard.pptxMustafa Ahmed
 
Autodesk Construction Cloud.pptx
Autodesk Construction Cloud.pptxAutodesk Construction Cloud.pptx
Autodesk Construction Cloud.pptxMustafa Ahmed
 
05- Augmented Reality.pptx
05- Augmented Reality.pptx05- Augmented Reality.pptx
05- Augmented Reality.pptxMustafa Ahmed
 
04- Data Analysis & BIM.pptx
04- Data Analysis & BIM.pptx04- Data Analysis & BIM.pptx
04- Data Analysis & BIM.pptxMustafa Ahmed
 
01- 3D Modeling.pptx
01- 3D Modeling.pptx01- 3D Modeling.pptx
01- 3D Modeling.pptxMustafa Ahmed
 
02- Coordination (Clash Detection).pptx
02- Coordination (Clash Detection).pptx02- Coordination (Clash Detection).pptx
02- Coordination (Clash Detection).pptxMustafa Ahmed
 

More from Mustafa Ahmed (7)

Power BI Dashboard.pptx
Power BI Dashboard.pptxPower BI Dashboard.pptx
Power BI Dashboard.pptx
 
Clash Detection Dashboard.pptx
Clash Detection Dashboard.pptxClash Detection Dashboard.pptx
Clash Detection Dashboard.pptx
 
Autodesk Construction Cloud.pptx
Autodesk Construction Cloud.pptxAutodesk Construction Cloud.pptx
Autodesk Construction Cloud.pptx
 
05- Augmented Reality.pptx
05- Augmented Reality.pptx05- Augmented Reality.pptx
05- Augmented Reality.pptx
 
04- Data Analysis & BIM.pptx
04- Data Analysis & BIM.pptx04- Data Analysis & BIM.pptx
04- Data Analysis & BIM.pptx
 
01- 3D Modeling.pptx
01- 3D Modeling.pptx01- 3D Modeling.pptx
01- 3D Modeling.pptx
 
02- Coordination (Clash Detection).pptx
02- Coordination (Clash Detection).pptx02- Coordination (Clash Detection).pptx
02- Coordination (Clash Detection).pptx
 

Recently uploaded

Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...amitlee9823
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Pooja Nehwal
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...SUHANI PANDEY
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsJoseMangaJr1
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 

Recently uploaded (20)

Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Bommasandra Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort ServiceBDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
BDSM⚡Call Girls in Mandawali Delhi >༒8448380779 Escort Service
 
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night StandCall Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Doddaballapur Road ☎ 7737669865 🥵 Book Your One night Stand
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Surabaya ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
Thane Call Girls 7091864438 Call Girls in Thane Escort service book now -
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Probability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter LessonsProbability Grade 10 Third Quarter Lessons
Probability Grade 10 Third Quarter Lessons
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 

SQL for Business Problems.pptx

  • 2. PROBLEM Using a CTE and the subscriptions and products tables to calculate for each product: • maximum and minimum monthly revenue • average monthly revenue • standard deviation of monthly revenue APPROACH DESCRIPTIVE STATISTICS WITH CTE The company is setting 2023 goals and needs insights into the monthly revenue distribution for Basic and Expert product subscriptions throughout 2022
  • 4. PROBLEM • Using Window Function to calculate the running total of sales revenue, running_total, and the % of quota reached, percent_quota, for each sales employee Using the sales and employees table. • cast() to convert the numerator a float APPROACH TRACKING RUNNING TOTALS WITH WINDOW FUNCTIONS The sales team is committed to achieving product sales, with set quotas that determine their commission earnings. Given the direct correlation between these goals and revenue, the team manager aims to monitor the performance of each sales member consistently over the course of the year.
  • 6. PROBLEM As users can go through statuses (fig1) we will use two CTEs and three tables: • Generate a CTE to compute the maxstatus reached for each subscriptionid within the paymentstatuslog table. • Next, form a CTE by combining the subscriptions table with the previously created CTE. This enables the utilization of the provided paymentfunnelstage code to classify each subscriptionid based on its maxstatus and currentstatus. • In a separate select statement below, count the number of subscriptionid per paymentfunnelstage . APPROACH PAYMENT FUNNEL ANALYSIS WITH CTE The product manager requested a payment funnel analysis from the analytics team to identify where users drop out in the payment process and gain full visibility into each stage from the user's perspective fig1
  • 8. PROBLEM • Using UNION and the cancelations table, calculate the percent of canceled subscriptions that reported 'Expensive' as one of their cancelation reasons. • Create cancel CTE • Calculate the percent of canceled subscriptions that reported 'Expensive' as one of their cancelation reasons. percent_expensive APPROACH UNPIVOTING COLUMNS INTO ROWS USING UNION Considering the challenging economic conditions, the initial focus is on extracting the percentage of canceled subscriptions attributed to the product being deemed too expensive. People have the option to choose up to three reasons from a predefined list. It's not possible for users to pick the same reason more than once, and some users may choose fewer than three reasons, resulting in null values for certain cancellation reason columns.
  • 10. PROBLEM Using a CTE and the frontendeventlog table to know how many users clicked the email link : • Count the number of users, num_users , in each num_link_clicks category • Filter by eventid = 5, as it’s accessed when the user reaches a unique landing page from this campaign email. APPROACH EXPLORING VARIABLE DISTRIBUTIONS WITH CTE The marketing team manager inquires about the effectiveness of the recent email campaign. After the campaign launch, they are interested in obtaining information about the number of users who clicked the link in the email.