SQL_Assignment 3
SQL_Assignment 3
Problem Statement:
The dataset contains information about passengers on the Titanic, including personal details
such as name, age, class, fare, survival status, and other related data. The goal is to analyze
this data using advanced MySQL features to answer specific business questions and provide
insights on passenger demographics, survival rates, and relationships between various
attributes.
Datasets Used:
Titanic Dataset
Objective:
The objective is to perform advanced data analysis and reporting on the Titanic passengers
dataset using key MySQL concepts, such as subqueries, views, stored procedures, CTE
(Common Table Expressions), and window functions like LEAD, LAG, RANK, and
DENSE_RANK.
1. Write a query to find the name and age of the oldest passenger who survived.
2. Create a view to display passenger survival status, class, age, and fare.
3. Create a stored procedure to retrieve passengers based on a given age range.
4. Write a query to categorize passengers based on the fare they paid: 'Low', 'Medium', or
'High'.
5. Show each passenger's fare and the fare of the next passenger.
6. Show the age of each passenger and the age of the previous passenger.
7. Write a query to rank passengers based on their fare, displaying rank for each passenger.
8. Write a query to rank passengers based on their fare, ensuring no gaps in rank
10. Use a CTE to calculate the average fare and find passengers who paid more than the
average.
Submit Guidelines:
Students can submit in SQL script files or word document