TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2632 2.7K
๐Ÿš€ SQL Project Series #22

Digital Marketing Campaign Analytics ๐Ÿ“ข

Analyze marketing campaigns, customers, leads, conversions, and advertising performance using SQL to optimize ROI and improve campaign effectiveness.

๐ŸŽฏ Business Objectives
โœ… Analyze marketing campaign performance
โœ… Track leads and conversions
โœ… Measure campaign ROI
โœ… Optimize advertising spend
โœ… Analyze customer acquisition
โœ… Measure conversion funnel
โœ… Evaluate marketing channels
โœ… Build executive marketing dashboards

๐Ÿ“‚ Step 1: Create Database
CREATE DATABASE marketing_analytics_db;
USE marketing_analytics_db;

๐Ÿ“‚ Step 2: Create Campaigns Table
CREATE TABLE campaigns (
campaign_id INT PRIMARY KEY,
campaign_name VARCHAR(100),
marketing_channel VARCHAR(50),
campaign_start DATE,
campaign_end DATE,
budget DECIMAL(12,2)
);

๐Ÿ“‚ Step 3: Create Customers Table
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100),
city VARCHAR(50),
acquisition_channel VARCHAR(50),
signup_date DATE
);

๐Ÿ“‚ Step 4: Create Leads Table
CREATE TABLE leads (
lead_id INT PRIMARY KEY,
campaign_id INT,
customer_id INT,
lead_date DATE,
lead_status VARCHAR(30),
conversion_date DATE,
FOREIGN KEY (campaign_id)
REFERENCES campaigns(campaign_id),
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id)
);

๐Ÿ“‚ Step 5: Insert Sample Campaigns
INSERT INTO campaigns VALUES
(101,'Summer Sale','Google Ads','2025-01-01','2025-01-31',500000),
(102,'New Year Offer','Facebook Ads','2025-01-05','2025-01-25',350000),
(103,'Email Promotion','Email','2025-01-10','2025-01-30',100000),
(104,'Influencer Campaign','Instagram','2025-01-15','2025-02-05',450000);

๐Ÿ“‚ Step 6: Insert Sample Customers
INSERT INTO customers VALUES
(1,'Rahul Sharma','Mumbai','Google Ads','2025-01-08'),
(2,'Priya Verma','Delhi','Facebook Ads','2025-01-10'),
(3,'Amit Patel','Pune','Email','2025-01-12'),
(4,'Sneha Joshi','Bangalore','Instagram','2025-01-18'),
(5,'Rohan Gupta','Hyderabad','Google Ads','2025-01-22');

๐Ÿ“‚ Step 7: Insert Sample Leads
INSERT INTO leads VALUES
(1001,101,1,'2025-01-03','Converted','2025-01-08'),
(1002,102,2,'2025-01-06','Converted','2025-01-10'),
(1003,103,3,'2025-01-12','Open',NULL),
(1004,104,4,'2025-01-18','Converted','2025-01-21'),
(1005,101,5,'2025-01-22','Lost',NULL);

๐Ÿง  SQL Concepts You'll Practice
โœ” DDL & DML
โœ” Joins
โœ” Aggregate Functions
โœ” GROUP BY
โœ” HAVING
โœ” CASE WHEN
โœ” CTEs
โœ” Window Functions
โœ” Date Functions
โœ” Marketing KPI Analysis

๐Ÿ“Š Business KPIs You Can Build
๐Ÿ“ˆ Total Campaigns
๐Ÿ“ˆ Total Leads
๐Ÿ“ˆ Total Conversions
๐Ÿ“ˆ Conversion Rate
๐Ÿ“ˆ Cost Per Lead (CPL)
๐Ÿ“ˆ Cost Per Acquisition (CPA)
๐Ÿ“ˆ Campaign ROI
๐Ÿ“ˆ Campaign Spend vs Revenue
๐Ÿ“ˆ Leads by Marketing Channel
๐Ÿ“ˆ Conversions by Marketing Channel
๐Ÿ“ˆ Customer Acquisition by Channel
๐Ÿ“ˆ Monthly Lead Trend
๐Ÿ“ˆ Monthly Conversion Trend
๐Ÿ“ˆ Average Conversion Time
๐Ÿ“ˆ Top Performing Campaigns
๐Ÿ“ˆ Lowest Performing Campaigns
๐Ÿ“ˆ Budget Utilization
๐Ÿ“ˆ Revenue by Campaign
๐Ÿ“ˆ Revenue by Marketing Channel
๐Ÿ“ˆ Customer Acquisition Cost (CAC)
๐Ÿ“ˆ Funnel Drop-off Analysis
๐Ÿ“ˆ Channel-wise Performance Dashboard
๐Ÿ“ˆ Campaign Performance Dashboard
๐Ÿ“ˆ Marketing Executive Dashboard

๐ŸŽฏ This project reflects real-world SQL analysis performed by Marketing Analysts, Growth Analysts, Performance Marketing teams, Product Analysts, and Business Intelligence professionals to optimize campaign performance and maximize return on investment.

Double Tap โค๏ธ For More
  • โค 12
More from @sqlanalyst
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026SQL Interview Series โ€” Part 4 ๐Ÿ“Œ Question 4: Find the Highest Salary in Each Department Suโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Sep 29, 2026SQL Interview Series โ€” Part 2 ๐Ÿ“Œ Question 2: Find Duplicate Records Suppose you have an Emโ€ฆ
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’