Questions and Answers On Ipl Database
Questions and Answers On Ipl Database
IPL DATABASE
1.Find the top 3 players with the highest total runs in all matches using INNER JOIN?
group by p.player_name
limit 3;
2.Find all players and their respective teams, including those who haven't played any matches
(use LEFT JOIN)?
3. Find the total number of matches played by each team using JOIN?
FROM teams t
GROUP BY t.team_name;
4.Get a list of all teams that have never won a match using LEFT JOIN?
SELECT t.team_name
FROM teams t
5.List all players who have played in matches won by their own team using JOIN?
FROM players p
6.Calculate the running total of runs scored by each player across all matches?
select p.player_name,p.player_id,pp.match_id,
from players p
7.Rank players based on their highest runs in a single match using RANK()?
FROM players p
FROM (
FROM players p
) AS ranked_players
WHERE rn <= 2;
9.Calculate the average runs scored per player over their last 3 matches using LAG()?
FROM players p
10.Calculate the total wickets taken by a bowler and rank them within their team using
DENSE_RANK()?
FROM players p
SELECT player_name,
CASE
ELSE 'Other'
END AS role_category
FROM players;
12. Use a CTE to find the total runs scored by players who have scored less than 1000 runs
across all matches?
WITH player_totals AS (
FROM players p
GROUP BY p.player_name
FROM players p
GROUP BY p.player_name
LIMIT 5;
14. Use a Subquery to find players who have played in more than 5 matches?
SELECT p.player_name
FROM players p
WHERE (SELECT COUNT(*) FROM performance per WHERE per.player_id = p.player_id) > 5;
15.Use CASE to calculate bonus points based on performance (e.g., runs scored and wickets
taken)?
SELECT player_id,
runs_scored,
wickets_taken,
CASE
ELSE 0
END AS bonus_points
FROM performance;