SQL Final
SQL Final
--------------
BATSMAN BATSMAN_SR
List of 10 batsman with high batting AD Russell 182.33
strike rate who have faced atleast 500 SP Narine 164.27
balls HH Pandya 159.27
V sehwag 155.44
GJ maxwell 154.68
RR pant 151.97
SELECT batsman, AB De villiers 151.91
ROUND((SUM(batsman_runs)*1.0 / CH gayle 150.11
COUNT(ball)) * 100,2) AS batsman_sr KA polard 149.88
FROM ipl_Ball JC buttler 149.56
WHERE extras_type not in ('wides')
GROUP BY 200
180
Batsman
182.33
160
HAVING COUNT(ball) > 500
164.27
159.27
155.44
154.68
151.97
140
151.91
150.11
149.88
149.56
ORDER BY 120
Batsman_sr
100
batsman_sr DESCLIMIT 10; 80
60
40
20
0
l l nt .
el in
e ya ag el l.. le rd tler
s s
a r nd
hw xw pa
vil
gay ola t
R
u N Pa s e a
R
R
D
e H p bu
m A
AD SP HH V
G
J
AB
C K JC
Batsman
BATSMAN RUNS AVERAGE
List of 10 players with best average who have KL RAHUL 2647 42.69
played more than 2 IPL seasons (or 28 matches) AB DE VILLIERS 4849 42.54
DA WARNER 5254 41.7
JP DUMINY 2029 41.41
SELECT CH GAYLE 4772 41.14
batsman, ML HAYDEN 1107 41
SUM(batsman_runs) AS runs, LMP SIMMONS 1079 39.96
KS WILLIAMSON 1619 39.49
ROUND(SUM(batsman_runs)*1.0/ SE MARSH 2477 38.7
SUM(is_wicket),2) AS average MEK HUSSEY 1977 38.02
FROM ipl_ball
GROUP BY 6000
5254
Batsman 5000 4849 4772
HAVING
4000
SUM(is_wicket) > 0 AND
3000 2647
COUNT(DISTINCT id) > 28 2477
AVERAGE
2029 1977
ORDER BY 2000 1619
1107 1079
average DESCLIMIT 10; 1000
RUNS
AVERAGE
0
S S
HUL ER NER INY YLE DEN ON SON RSH SEY
I
RA ILL AR DU
M GA
AY IMM IAM M
A
HUS
L W P H H
K V
J C L S
IL
L SE EK
DE DA M M
P
W M
AB L
KS
BATSMAN
List of 10 players who have scored BATSMAN
SP NARINE
BOUNDARY_PERCENTAGE
81.17
most runs in boundaries and have AD RUSSELL 78.71
CH GAYLE 76.07
played more than 2 IPL seasons(more ST JAYASURIYA 74.22
than 28 matches). AC GILCHRIST 72.89
V SEHWAG 72.29
SELECT DR SMITH 70.52
batsman, CA LYNN 69.53
HARBHAJAN 68.52
ROUND (SUM(CASE WHEN batsman...runs in(4,6) SR WATSON 68.25
THEN batsman.runs else 0 END)*1.0/
SUM(batsman...cuns)*100,2) AS boundary
percentage. 85
81.17
FROM jol ball 78.71
80
WHER 76.07
74.22
Eextras type NOT IN ('wides') 75 72.89 72.29
P-ERCENTAGE
70.52 69.53
GROUP BY 70 68.52 68.25
batsman 65
HAVING
60
COUNT(DISTINCT id) > 28
E L E A ST N
IN EL YL AG IT
H N N
ORDER BY R SS A R IY
HRI W M LYN AJA TSO
NA RU
G
AS
U C SE
H
R
S
CA BH
A
boundary percentage DESCLIMIT 10; SP
AD
C H
AY GIL V D
AR
SR
W
J AC H
ST
BATSMAN
BOWLER ECONOMY
RASHID KHAN 6.33
List of 10 bowlers with best economy who have A KUMBLE 6.65
bowled at least 500 balls in IPL M MURALATHIRAN 6.68
DW STEYN 6.77
R ASHWIN 6.77
SELECT SP NARINE 6.82
bowler, DL VETTORI 6.83
ROUND(SUM(total_runs)/(COUNT(bowler)/6.0), 2) WASHINGTON SUNDAR 6.89
as economy J BOTHA 6.92
R TEWATIA 6.99
FROM ipl_ball
GROUP BY
7.2
Bowler 6.89 6.92
6.99
7 6.82 6.83
HAVING 6.8 6.65 6.68
6.77 6.77
6.2
economy 6
LIMIT 10; AN
E N YN IN E
OR
I
AR HA TI
A
BL RA E IN T
KH M I
ST HW R T T ND O A
D KU TH AS NA VE SU JB
W
HI A LA DW R SP L N TE
S A D O R
RA UR GT
N
M HI
M AS
W
BOWLER
List of 10 bowlers who have the best strike rate and BOWLER BOWLING SR
K RABADA 13.77
who gave bowled at least 500 balls AJ TYE 16.13
DE BOLLINGER 16.22
WITH ValidDismissals AS ( IMRAN TAHIR 16.43
SL MALINGA 17.49
SELECT S ARAVIND 17.51
bowler, MA STARC 18
YS CHAHAL 18.08
is_wicket, KK COOPER 18.18
CASE TA BOULT 18.29
WHEN dismissal_kind IN ('bowled', 'caught', 'caught
and bowled', 'hit wicket', 'lbw', 'stumped')
THEN 1 20
18
17.49 17.51 18 18.08 18.18
18.29
16.13 16.22 16.43
ELSE 0 16
13.77
END AS is_valid_dismissal 14
12
FROM ipl_ball) 10 BOWLING SR
SELECT bowler, 8
6
ROUND(COUNT(bowler) * 1.0 / 4
SUM(is_valid_dismissal),2) AS economy 2
0
FROM ValidDismissals E L T
DA TY GE
R
HI
R GA IN
D RC HA PE
R
UL
GROUP BY bowler B A J IN TA IN V TA A O O
RA
A
LL N AL RA A
S
CH CO A
B
A
HAVING COUNT(bowler) > 500 K B O R A
SL
M S M YS K K T
DE IM
ORDER BY
BOWLER
economy LIMIT 10;
BOWLIN
List of 10 allrounders who have the best bowling and batting strike
ALLROUNDER PLAYERS BATTING SR G SR
rate and who gave faced at least 500 balls and bowled at least 300 AD RUSSELL 182.33 19.4
SP NARINE 164.27 22.2
balls. HH PANDYA 159.27 21.8
HGJ MAXWEL 154.68 29.4
CH GAYLE 150.11 32.4
SELECT
KA POLLARD 149.88 23.6
a.batsman AS all_rounder ST JAYASURIYA 144.36 23.2
a.batsman_sr, YK PATHAN 142.97 28.2
b.bowling_sr KH PANDYA 142.45 27.9
JA MORKEL 141.98 21.3
FROM batting_sr a
INNER JOIN 35
bowling_sr b ON a.batsman = b.bowler 30
ORDER BY 25
200 20
a.batsman_sr DESC,
32.44
29.37
BOWLING SR
28.19
27.89
15
b.bowling_sr ASC 160
23.57
23.15
22.24
21.76
21.26
19.44
10
LIMIT 10; 120
182.33
5
164.27
159.27
154.68
150.11
149.88
BATTING SR
144.36
142.97
142.45
141.98
80 0
E A L E D A N A L
40 ELL IN DY WE YL AR IY HA DY KE
R R
USS NA AN AX GA LL SU AT AN OR
0 R SP H J M CH P YA K P H P A M
P O
AD H G KA JA Y K J
L NE A EL LE D A N A EL H
ST
SEL RI NDY W AY LAR RIY THA NDY RK
S NA A AX G L SU A A O
RU SP H P J M CH PO YA K P H P A M PLAYERS
AD H G KA JA Y K J
H
ST
PLAYERS
The most important criteria for selecting WICKETKEEPERS in the
IPL.
Batting Ability: Prioritize wicketkeepers who can score quickly and hit boundaries,
contributing to the team's run total.
Agility and Glovework: Strong wicketkeeping skills are vital. Look for wicketkeepers
with quick reflexes, clean catching ability, and accurate stumpings.
Experience: Consider wicketkeepers with T20 experience who can handle pressure
situations effectively.
Versatility: Choose wicketkeepers who can adapt to different match scenarios and
contribute effectively in various batting positions.
Leadership and Communication: Wicketkeepers who can lead the fielding unit and
effectively communicate with bowlers and fielders are valuable.
Consistency: Look for wicketkeepers with a consistent track record, both in batting
and wicketkeeping, to ensure stable performance throughout the tournament.
ADDITIONAL QUESTIONS
1. Get the count of cities that have hosted an IPL match.
CITY_COUNTS
33
2. Create table deliveries_v02 with all the columns of the table
‘deliveries’ and an additional column ball_result containing values
boundary, dot or other depending on the total_run (boundary for >= 4,
dot for 0 and other for any other number)
BOUNDARIES_COUNTS DOTBALL_COUNTS
31468 67841
4. Write a query to fetch the total number of boundaries scored by
each team from the deliveries_v02 table and order it in descending
order of the number of boundaries scored.
TEAM TOTAL_BOUNDARIES
MUMBAI INDIANS 4118
TOTAL_DISMISSALS_NOT_NA
9495
7. Write a query to get the top 5 bowlers who conceded maximum
extra runs from the deliveries table.
BOWLER RUNS_CONCEDED
SL MALINGA 293
P KUMAR 236
UT YADAV 226
DJ BRAVO 210
B KUMAR 201
8. Write a query to create a table named deliveries_v03 with all the columns of
deliveries_v02 table and two additional column (named venue and
match_date) of venue and date from table matches.
venue and order it in the descending order of total SAWAI MANSINGH STADIUM
PANJAB CRICKET ASSOCIATION STADIUM, MOHALI
runs scored. DUBAI INTERNATIONAL CRICKET STADIUM
SHEIKH ZAYED STADIUM
PANJAB CRICKET ASSOCIATION IS BINDRA STADIUM,
MAHARASTRA CRICKET ASSOCIATION STADIUM
SHARJAHA CRICKET STADIUM
M CHINNASWAMY STADIUM
DR DY PATIL SPORTS ACADEMY
SUBRATA ROY SAHARA STADIUM
KINGSMEAD
BRABOURNE STADIUM
DR Y S RAJASEKHAR REDDY ACA-VDCA CRICKET STADIUM
SARDAR PATEL STADIUM,MOTERE
SUPERSPORT PARK
SAUSHTRA CRICKET ASSOCIATION STADIUM
HIMACHAL PRADESH CRICKET ASSOCIATION STADIUM
HOLKAR CRICKET STADIUM
NEW WANDERERS STADIUM
BARABATI STADIUM
JSCA INTERNATIONAL STADIUM COMP-LEX
ST GEORGES PARK
NEWLANDS
SHAHEED VEER NARAYAN SINGH INTERNATIONAL STADIUM
NEHRU STADIUM
GREEN PARK
DE BEERS DIAMOND OVAL
VIDRABHA CRICKET ASSOCIATION STADIUM,JAMTHA
BUFFALO PARK
OUTSURANCE OVAL
10. Write a query to fetch the year-wise total runs scored at Eden
Gardens and order it in the descending order of total runs scored.
YEAR ENDENGARDEN_RUNS_SCORED
2018 2885
2019 2651
2015 2386
2013 2304
2017 2194
2010 2167
2016 2073
2012 2012
2011 1854
2008 1843
2014 1289
THANK YOU