0% found this document useful (0 votes)
7 views

Assignment_5

Uploaded by

lizzmc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Assignment_5

Uploaded by

lizzmc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

use IPL_DATABASE.

ipl_schema;

--1. Display the average powerplay score, maximum middle overs score, minimum death
overs scores for the matches played in 2008 season.
select round(avg(powerplay_scores), 2) as avg_powerplay_score,
max(middle_overs_scores) as max_middleover_score,
min(death_overs_scores) as min_deathover_scores
from team_performance
group by match_date
having extract(year from match_date) = 2008
;

--2. How many times did ZAHEER KHAN bowled each batsmen in the entire IPL seasons.
select striker, count(*) as zaheer_khan_bowled from ipl_ballbyball
where bowler ilike '%z khan%'
group by striker;

--3. Display all the players who got run out while taking the second run.
select striker, non_striker from ipl_ballbyball
where wicket_type ilike '%run out%' and runs_scored = 2;

--4. Display all the players who got run out when they were on non strickers.
select non_striker from ipl_ballbyball
where wicket_type ilike '%run out%' and player_out = non_striker;

--5. Display number of extras conceded in each match and every innings.
select match_id, innings_number, sum(extra) as tot_extras from ipl_ballbyball
where extra > 0
group by match_id, innings_number;

--6. Display total number of boundaries scored on every weekend in the matches
played after 2020.
select match_id, count(*) as total_boundaries from ipl_ballbyball
where runs_scored in (4,6) and (extract(day from match_date) ilike '%sun%' or
extract(day from match_date) ilike '%sat%') and season >2020;

--7. Display how many times Virat Kohli got out as a second wicket.
select count(distinct match_id) as virat_out from ipl_ballbyball
where split_part(score_wicket, '/', 2) = '2';

--9. Display all the players who got stumped more than 5 times in their career.
select striker from ipl_ballbyball
where wicket_type = 'stumped'
group by striker
having count(*) > 5;

--10. Display the bowlers who bowled less than 2 overs and conceded more than 40
runs
select bowler, sum(runs_scored) as total_runs, sum(ball_number) as total_balls from
ipl_ballbyball
group by bowler
having sum(runs_scored) > 40 and sum(ball_number) < 12;

You might also like