Skip to content

A structured SQL analysis of Major League Baseball (MLB) data using analytical queries and window functions.

License

Notifications You must be signed in to change notification settings

ameerahrazali/mlb-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MLB SQL Analysis

This project presents a structured analysis of Major League Baseball (MLB) data using SQL and visualized through Tableau dashboards. The analysis spans player statistics, school affiliations, and team salary trends, offering multi-perspective insights into the MLB landscape.


Project Structure

The SQL and dashboard components are organized into four key areas:

Part Topic Key Analyses
I School Analysis • Join schools + school_details
• Count schools by decade
• Top 5 schools overall
• Top 3 schools per decade
II Salary Analysis • View salary data
• Top 20% teams by average spend
• Cumulative salary over years
• Year teams surpassed $1B
III Player Career Analysis • Age at debut and final game
• Career length in years
• Start and end teams
• 10+ years on same team
IV Player Comparison Analysis • Players with shared birthdays
• Batting style breakdown by team
• Debut height/weight by decade
• Decade-over-decade differences

Files Included

  • final_project.sql: Main SQL script containing all structured queries and insights.
  • assets/ folder:
    • MLB_Salary.gif: Animated preview of the salary dashboard.
    • MLB_Players.gif: Animated preview of the player analysis dashboard.
    • MLB_School.gif: Animated preview of the school-level dashboard.
    • Major League Baseball Analysis.twb: Tableau Workbook file containing all dashboards.

Note: Tableau dashboards were created using Tableau Desktop and are not hosted on Tableau Public due to publishing limitations.


Tableau Dashboard Themes

1. MLB Salary Landscape

Spending, Trends & Top Earners

  • Top 10 highest-paid players
  • KPI cards on salary spending
  • Salary trend by year and team

MLB Salary Dashboard


2. MLB Player Careers

Debuts, Longevity & Profiles

  • Career spans across decades
  • Player debut patterns
  • KPI cards and highlight metrics

MLB Player Dashboard


3. MLB School Impact

School Contributions & Legacy

  • Player origins by school and state
  • Total salary by school
  • Career duration and performance funnels

MLB School Dashboard


Tools Used

  • MySQL
  • Tableau Desktop (for dashboard creation)
  • Maven Analytics MLB dataset
  • SQL window functions, CTEs, aggregates

Key Skills Demonstrated

  • Analytical SQL for real-world data exploration
  • Use of ROW_NUMBER, NTILE, LAG, and other advanced functions
  • Data summarization, blending, and transformation
  • Custom dashboard storytelling using Tableau

Getting Started

To explore or reproduce the analysis:

  1. Import the database maven_advanced_sql into your SQL environment.
  2. Run the queries from final_project.sql step by step.
  3. Open Major League Baseball Analysis.twb in Tableau Desktop to view dashboards.
  4. Preview dashboards from the GIFs in the assets folder.

Acknowledgments

This project uses data from the Maven Analytics Advanced SQL course. It was created for educational and portfolio purposes.

About

A structured SQL analysis of Major League Baseball (MLB) data using analytical queries and window functions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published