TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst ยท 76.7K subscribers
Post #2593 2.18K
๐Ÿš€ SQL Project Series #7

Hospital Management Analysis ๐Ÿฅ

Learn how hospitals use SQL to analyze patient data, optimize operations, improve resource utilization, and generate healthcare insights.

๐ŸŽฏ Business Objectives
โœ… Analyze patient admissions
โœ… Monitor doctor performance
โœ… Track appointment trends
โœ… Measure bed occupancy
โœ… Analyze treatment costs
โœ… Identify readmitted patients
โœ… Calculate average length of stay
โœ… Improve hospital efficiency

๐Ÿ“‚ Step 1: Create Database

CREATE DATABASE hospital_db;

USE hospital_db;


๐Ÿ“‚ Step 2: Create Patients Table

CREATE TABLE patients (
patient_id INT PRIMARY KEY,
patient_name VARCHAR(100),
gender VARCHAR(10),
age INT,
city VARCHAR(50),
registration_date DATE
);


๐Ÿ“‚ Step 3: Create Doctors Table

CREATE TABLE doctors (
doctor_id INT PRIMARY KEY,
doctor_name VARCHAR(100),
specialization VARCHAR(100),
department VARCHAR(100)
);


๐Ÿ“‚ Step 4: Create Appointments Table

CREATE TABLE appointments (
appointment_id INT PRIMARY KEY,
patient_id INT,
doctor_id INT,
appointment_date DATE,
status VARCHAR(20),
consultation_fee DECIMAL(10,2),
FOREIGN KEY (patient_id) REFERENCES patients(patient_id),
FOREIGN KEY (doctor_id) REFERENCES doctors(doctor_id)
);


๐Ÿ“‚ Step 5: Create Admissions Table

CREATE TABLE admissions (
admission_id INT PRIMARY KEY,
patient_id INT,
admission_date DATE,
discharge_date DATE,
diagnosis VARCHAR(100),
treatment_cost DECIMAL(12,2),
FOREIGN KEY (patient_id) REFERENCES patients(patient_id)
);


๐Ÿ“‚ Step 6: Insert Sample Patients

INSERT INTO patients VALUES
(1,'Rahul Sharma','Male',34,'Mumbai','2024-01-05'),
(2,'Priya Verma','Female',29,'Delhi','2024-01-10'),
(3,'Amit Patel','Male',42,'Pune','2024-02-15'),
(4,'Sneha Joshi','Female',37,'Bangalore','2024-03-01'),
(5,'Rohan Gupta','Male',51,'Hyderabad','2024-03-20');


๐Ÿ“‚ Step 7: Insert Sample Doctors

INSERT INTO doctors VALUES
(101,'Dr. Mehta','Cardiology','Heart Care'),
(102,'Dr. Singh','Orthopedics','Bone Care'),
(103,'Dr. Rao','Neurology','Neuro Care'),
(104,'Dr. Shah','General Medicine','General');


๐Ÿ“‚ Step 8: Insert Sample Appointments

INSERT INTO appointments VALUES
(1001,1,101,'2025-01-05','Completed',800),
(1002,2,104,'2025-01-06','Completed',500),
(1003,3,102,'2025-01-08','Cancelled',700),
(1004,4,103,'2025-01-09','Completed',1000),
(1005,5,101,'2025-01-12','Completed',800);


๐Ÿ“‚ Step 9: Insert Sample Admissions

INSERT INTO admissions VALUES
(201,1,'2025-01-05','2025-01-10','Heart Surgery',250000),
(202,2,'2025-01-08','2025-01-11','Fever',12000),
(203,3,'2025-01-15','2025-01-22','Fracture',85000),
(204,5,'2025-01-18','2025-01-21','Cardiac Checkup',45000);


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

๐Ÿ“Š Business KPIs You Can Build
๐Ÿ“ˆ Total Patients
๐Ÿ“ˆ Total Admissions
๐Ÿ“ˆ Total Appointments
๐Ÿ“ˆ Appointment Completion Rate
๐Ÿ“ˆ Appointment Cancellation Rate
๐Ÿ“ˆ Doctor-wise Patient Count
๐Ÿ“ˆ Department-wise Revenue
๐Ÿ“ˆ Average Consultation Fee
๐Ÿ“ˆ Average Treatment Cost
๐Ÿ“ˆ Average Length of Stay
๐Ÿ“ˆ Daily Patient Admissions
๐Ÿ“ˆ Monthly Admission Trend
๐Ÿ“ˆ Readmission Rate
๐Ÿ“ˆ Bed Occupancy Rate
๐Ÿ“ˆ Top Doctors by Patient Volume
๐Ÿ“ˆ Revenue by Department
๐Ÿ“ˆ Revenue by Doctor
๐Ÿ“ˆ Most Common Diagnosis
๐Ÿ“ˆ Patient Distribution by City
๐Ÿ“ˆ Average Patient Age

๐ŸŽฏ This project reflects the type of SQL analysis performed by Healthcare Analysts, Hospital Operations teams, Business Intelligence Analysts, and Data Analysts working in hospitals and health-tech companies.

๐Ÿ’ก Double Tap โค๏ธ For More
  • โค 13
  • ๐ŸŽ‰ 2
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 โ†’