TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2612 3.42K
๐Ÿš€ SQL Project Series #14

Social Media Analytics ๐Ÿ“ฑ
Analyze users, posts, likes, comments, shares, and engagement metrics using SQL to understand user behavior and platform growth.

๐ŸŽฏ Business Objectives
โœ… Analyze user growth
โœ… Measure content engagement
โœ… Track active users
โœ… Identify trending posts
โœ… Analyze creator performance
โœ… Monitor user retention
โœ… Measure platform activity
โœ… Build engagement dashboards

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

๐Ÿ“‚ Step 2: Create Users Table
CREATE TABLE users (
user_id INT PRIMARY KEY,
user_name VARCHAR(100),
city VARCHAR(50),
join_date DATE
);

๐Ÿ“‚ Step 3: Create Posts Table
CREATE TABLE posts (
post_id INT PRIMARY KEY,
user_id INT,
post_date DATE,
content_type VARCHAR(30),
views INT,
FOREIGN KEY (user_id)
REFERENCES users(user_id)
);

๐Ÿ“‚ Step 4: Create Engagement Table
CREATE TABLE engagement (
engagement_id INT PRIMARY KEY,
post_id INT,
likes INT,
comments INT,
shares INT,
FOREIGN KEY (post_id)
REFERENCES posts(post_id)
);

๐Ÿ“‚ Step 5: Insert Sample Users
INSERT INTO users VALUES
(1,'Rahul','Mumbai','2024-01-10'),
(2,'Priya','Delhi','2024-02-15'),
(3,'Amit','Pune','2024-03-08'),
(4,'Sneha','Bangalore','2024-04-05'),
(5,'Rohan','Hyderabad','2024-05-12');

๐Ÿ“‚ Step 6: Insert Sample Posts
INSERT INTO posts VALUES
(101,1,'2025-01-05','Image',1200),
(102,2,'2025-01-06','Video',5400),
(103,3,'2025-01-06','Reel',8900),
(104,4,'2025-01-07','Image',2500),
(105,5,'2025-01-08','Video',6100);

๐Ÿ“‚ Step 7: Insert Sample Engagement
INSERT INTO engagement VALUES
(1,101,180,22,15),
(2,102,520,84,60),
(3,103,950,145,110),
(4,104,240,35,20),
(5,105,610,92,70);

๐Ÿง  SQL Concepts You'll Practice
โœ” DDL & DML
โœ” INNER JOIN
โœ” LEFT JOIN
โœ” Aggregate Functions
โœ” GROUP BY
โœ” HAVING
โœ” CASE WHEN
โœ” Window Functions
โœ” CTEs
โœ” Date Functions

๐Ÿ“Š Business KPIs You Can Build
๐Ÿ“ˆ Total Users
๐Ÿ“ˆ New Users by Month
๐Ÿ“ˆ Daily Active Users (DAU)
๐Ÿ“ˆ Monthly Active Users (MAU)
๐Ÿ“ˆ Total Posts
๐Ÿ“ˆ Posts by Content Type
๐Ÿ“ˆ Total Views
๐Ÿ“ˆ Average Views per Post
๐Ÿ“ˆ Total Likes
๐Ÿ“ˆ Total Comments
๐Ÿ“ˆ Total Shares
๐Ÿ“ˆ Engagement Rate
๐Ÿ“ˆ Average Engagement per User
๐Ÿ“ˆ Top 10 Creators
๐Ÿ“ˆ Most Viewed Posts
๐Ÿ“ˆ Most Liked Posts
๐Ÿ“ˆ Most Shared Posts
๐Ÿ“ˆ User Retention Rate
๐Ÿ“ˆ Content Performance by Type
๐Ÿ“ˆ City-wise User Distribution
๐Ÿ“ˆ Posting Trend by Month
๐Ÿ“ˆ Viral Content Analysis
๐Ÿ“ˆ Creator Growth Analysis
๐Ÿ“ˆ Platform Growth Dashboard
๐Ÿ“ˆ Executive Social Media Dashboard

This project reflects real-world SQL analysis performed by Product Analysts, Growth Analysts, Marketing Analysts, and Business Intelligence teams at companies like Instagram, Facebook, LinkedIn, X, and YouTube.

๐Ÿ’ก Double Tap โค๏ธ For More
  • โค 14
  • ๐Ÿ‘ 1
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 โ†’