This project explores a real-world layoffs dataset to uncover trends across companies, time periods, industries, and regions.
The goal is to answer key questions such as:
- Which companies laid off the most employees?
- When did layoffs peak?
- Which countries and stages were most affected?
- Are layoffs random or pattern-driven?
The dataset contains:
- Company name
- Date of layoff
- Total employees laid off
- Percentage of workforce laid off
- Company stage
- Country
- Funds raised (in millions)
- SQL (MySQL)
- Window Functions
- Common Table Expressions (CTEs)
- Checked overall dataset structure
- Identified missing and extreme values
- Total layoffs per company
- Companies with repeated layoffs
- Layoffs by year and date
- Monthly trend analysis
- Rolling cumulative layoffs over time
- Layoffs by country
- Layoffs by company stage (Startup, Growth, etc.)
- Companies with 100% layoffs
- Top 5 companies per year using
DENSE_RANK()
- Layoffs are not random; they follow clear time-based trends
- Certain months show significant spikes, indicating economic events
- Some companies laid off 100% of employees, even after raising large funds
- A small number of companies contributed to a large share of total layoffs
- Layoffs occurred across all stages, including late-stage companies
GROUP BYfor aggregationDATE_FORMAT()andYEAR()for time analysisSUM() OVER()for rolling totalsDENSE_RANK()for ranking within groups- CTEs for structured and readable queries
WITH Company_Year AS (
SELECT company, YEAR(date) AS years, SUM(total_laid_off) AS total_laid_off
FROM layoff_staging2
GROUP BY company, YEAR(date)
),
Company_Year_Rank AS (
SELECT *,
DENSE_RANK() OVER (PARTITION BY years ORDER BY total_laid_off DESC) AS ranking
FROM Company_Year
WHERE years IS NOT NULL
)
SELECT *
FROM Company_Year_Rank
WHERE ranking <= 5;- Add data visualizations (Python / Power BI / Tableau)
- Clean and standardize company & country names
- Combine with external economic indicators
- Build an interactive dashboard
This project demonstrates how SQL can be used not just for querying data, but for extracting meaningful insights and identifying real-world trends.
⭐ If you found this useful, feel free to star the repo!