2. Understanding the Medicare Readmission Dataset with SQL

Objective

Now that we have downloaded the raw Medicare data, we need to understand what’s inside the file before we start analyzing it. In this post, we will explore the dataset structure using SQL.

Step 1: Import Data into SQL

Open your SQL tool (MySQL, SQL Server, or PostgreSQL)
Create a new database called Hospital_Readmissions
Import the CSV file into a table named Hospital_Readmissions

Example: Microsoft SQL Serve Management Studio (SSMS)

Step 2: Explore the Dataset Structure Run this SQL query to see all the column names and understand what data we have:

SQL

SELECT * 
FROM Hospital_Readmissions

Key Columns to Focus On

  • hospital_name
  • measure_name — This tells us the medical condition (Heart Failure, Pneumonia, etc.)
  • number_of_discharges
  • number_of_readmissions
  • excess_readmission_ratio
  • readmission_rate

Step 3: Check Basic Statistics Run this query to understand the size of our dataset:

SQL

SELECT
	COUNT(*) AS Total_Rows,
	COUNT(DISTINCT Facility_Name) AS Total_Facilities,
	COUNT(DISTINCT Measure_Name) AS Total_Condition
FROM Hospital_Readmissions;

This will tell us how many hospitals and conditions are included in the data.

Next Post

In the next post, I will show you how to clean this messy raw data using SQL — removing duplicates, handling missing values, and preparing the data for analysis.

Previous: Part 1. How to Download Medicare Hospital Readmission Data

Next: Part 3. Cleaning Medicare Hospital Readmission Data with SQL

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top