SlideShare a Scribd company logo
1 of 22
PRESENTATION
ON
IPL AUCTION STRATEGY
CREATED BY : SUDHANSHU WALIA
COURSE NAME : DATA SCIENCE
INTERNSHALA TRAININGS
CREATED IPL PLAYER DATAAS ipl_player_data FROM IPL_BALL.CSV FILE
CREATE TABLE ipl_player_data
(id int,inning int,over int,ball int,batsman char(50),non_striker char(50),bowler char(50),batsman_runs int,
extra_runs int,total_runs int,is_wicket int,dismissal_kind char(50),player_dismissed char(50),fielder char(50),
extras_type char(50),batting_team varchar(50),bowling_team varchar(50) );
--COPYING CSV FILE QUERY :
COPY ipl_player_data FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_Ball.csv'
DELIMITER ',' CSV HEADER;
--QUERY TO RETRIEVE DATA :
SELECT * FROM ipl_player_data;
CREATED IPL MATCH DATAAS ipl_match_data FROM IPL_MATCHES.CSV FILE
CREATE TABLE ipl_match_data
(id int,city char(50),match_date varchar(50),player_of_match char(50),venue varchar(255),neutral_venue varchar(255),
team1 varchar(100),team2 varchar(100),toss_winner varchar(100),toss_decision char(50),winner varchar(100),
result varchar(50),result_margin int,eliminator char(10),method varchar(50),umpire1 char(50),umpire2 char(50)
);
--COPYING CSV FILE QUERY :
COPY ipl_match_data FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_matches.csv' DELIMITER ','
CSV HEADER;
--ALTER THE DATATYPE OF match_date COLUMN TO DATE DATATYPE
ALTER TABLE ipl_match_data ALTER COLUMN match_date TYPE DATE USING to_date(match_date,'DD-MM-
YYYY’);
--QUERY TO RETRIEVE DATA :
select * from ipl_match_data;
Q1:Your first priority is to get 2-3 players with high S.R who have faced at least 500 balls.And to do that
you have to make a list of 10 players you want to bid in the auction so that when you try to grab them
in auction you should not pay the amount greater than you have in the purse for a particular player.
SELECT batsman ,cast(strike_rate as decimal(4,1)),DENSE_RANK() OVER (ORDER BY strike_rate DESC) AS player_rank
FROM(
SELECT batsman,CAST (player_total_runs as float)/balls_faced*100 as strike_rate
FROM( SELECT batsman,sum(batsman_runs) AS player_total_runs,
count(ball) AS balls_faced FROM ipl_player_data WHERE NOT extras_type ='wides'
GROUP BY batsman) AS a WHERE balls_faced>500 ) AS b ORDER BY strike_rate DESC LIMIT 10;
182.3
164.3
159.3
155.4
154.7
152
151.9
150.1
149.9
149.6
AD Russell
SP Narine
HH Pandya
V Sehwag
GJ Maxwell
RR Pant
AB de Villiers
CH Gayle
KA Pollard
JC Buttler
Batsman Strike_Rate
Q2: Now you need to get 2-3 players with good Average who have played more than 2 ipl seasons. And
to do that you have to make a list of 10 players you want to bid in the auction so that when you try to
grab them in auction you should not pay the amount greater than you have in the purse for a
particular player
SELECT batsman,player_average,DENSE_RANK() OVER (ORDER BY player_average DESC)
FROM ( SELECT *,cast(AVG(total_runs/dismissed_no) as decimal(3,1) )AS player_average
FROM( select batsman,sum(batsman_runs) as total_runs,
sum(is_wicket) as dismissed_no,count(distinct extract(year from match_date)) as played_years
from (SELECT a.batsman, a.batsman_runs, a.is_wicket, b.match_date
FROM ipl_player_data as a full join ipl_match_data as b
on a.id=b.id ) AS c GROUP BY batsman
) as d group by batsman,total_runs,dismissed_no,
played_years having dismissed_no>=1 and played_years>2 ORDER BY player_average DESC) as e LIMIT 10;
88
42 42 41 41 41 41 39 39 38
Batsman With Good Average
Q3: Now you need to get 2-3 Hard-hitting players who have scored most runs in boundaries and have
played more the 2 ipl season. To do that you have to make a list of 10 players you want to bid in the
auction so that when you try to grab them in auction you should not pay the amount greater than you
have in the purse for a particular player.
select batsman,cast(boundary_percentage as decimal(3,1)),DENSE_RANK() OVER (ORDER BY boundary_percentage DESC) from(
select *,(cast(boundary_runs as float)/total_runs*100) as boundary_percentage
from ( SELECT batsman,total_runs,SUM(batsman_runs) AS boundary_runs,
COUNT(batsman_runs) AS boundaries_total,count(distinct extract(year from match_date)) as played_years
from (SELECT a.batsman,a.batsman_runs,SUM(a.batsman_runs) OVER (PARTITION BY a.batsman) as total_runs,
b.match_date FROM ipl_player_data as a full join ipl_match_data as b
on a.id=b.id ) as c WHERE batsman_runs=4 or batsman_runs=6 group by total_runs,batsman order by boundaries_total DESC
) as d where played_years>2 order by boundary_percentage desc ) as e limit 10 ;
81.2
78.7
76.1
75.1
74.2
73.1 72.9 72.9 72.7 72.4
Player with most boundary_percentage
Q4: Your first priority is to get 2-3 bowlers with good economy who have bowled at least 500 balls in
IPL so far.To do that you have to make a list of 10 players you want to bid in the auction so that when
you try to grab them in auction you should not pay the amount greater than you have in the purse for
a particular player
select bowler,cast(economy as decimal(2,1)),DENSE_RANK() OVER (ORDER BY economy asc) from(
select *,conceded_runs/cast(bowled_overs as decimal) as economy from(
select bowler,conceded_runs,bowled_balls,count(ball)/6||'.'||count(ball)%6 as bowled_overs
from( SELECT bowler,ball, sum(total_runs) over (partition by bowler) as conceded_runs,
count(ball) over (partition by bowler) as bowled_balls,over
from ipl_player_data ) as a where bowled_balls>500 group by bowler,conceded_runs,bowled_balls) as b
) as c limit 10 ;
6.3
6.7
6.7
6.8
6.8
6.8
6.9
6.9
6.9
7
Rashid Khan
A Kumble
M Muralitharan
DW Steyn
R Ashwin
SP Narine
DL Vettori
Washington Sundar
J Botha
R Tewatia
Bowler's Economy
Q5: Now you need to get 2-3 bowlers with the best strike rate and who have bowled at least 500 balls
in IPL so far.To do that you have to make a list of 10 players you want to bid in the auction so that when
you try to grab them in auction you should not pay the amount greater than you have in the purse for
a particular player
select bowler,cast(strike_rate as decimal(3,1)),DENSE_RANK() OVER (ORDER BY strike_rate) from (
select *,cast(total_balls as float)/wicket_taken as strike_rate from (
select bowler,total_balls,sum(is_wicket) as wicket_taken from (
select bowler,is_wicket,count(ball) over (partition by bowler) as total_balls from ipl_player_data ) as a
where is_wicket>0 and total_balls>500
group by bowler,total_balls )as b order by strike_rate asc limit 10 )as c
12.7
14
14.3
15.7
15.8
15.8
16.3
16.3
16.4
16.7
K Rabada
DE Bollinger
AJ Tye
MA Starc
SL Malinga
Imran Tahir
DJ Bravo
A Nehra
S Aravind
KK Cooper
Bowler's Strike Rate
Q6: Now you need to get 2-3 All_rounders with the best batting as well as bowling strike rate and who
have faced at least 500 balls in IPL so far and have bowled minimum 300 balls.To do that you have to
make a list of 10 players you want to bid in the auction so that when you try to grab them in auction
you should not pay the amount greater than you have in the purse for a particular player.
create table bats_sr as ( select batsman,cast(player_total_runs as decimal)/balls_faced*100 as batting_sr from(
SELECT batsman,sum(batsman_runs) AS player_total_runs,
count(ball) AS balls_faced FROM ipl_player_data WHERE NOT extras_type ='wides'
GROUP BY batsman having count(ball)>500 ) as a )
create table bowl_sr as (select bowler,cast(total_balls as decimal)/wicket_taken as bowling_sr from(
select bowler,total_balls,sum(is_wicket) as wicket_taken from (
select bowler,is_wicket,count(ball) over (partition by bowler) as total_balls from ipl_player_data ) as a
where is_wicket>0 and total_balls>300
group by bowler,total_balls) as a )
select a.batsman as allrounder,cast(a.batting_sr as decimal(4,1)),cast(b.bowling_sr as decimal(3,1))
from bats_sr as a inner join bowl_sr as b on a.batsman=b.bowler where batting_sr>150 and bowling_sr<21
182.3 164.3 159.3
17.7
19.7 20.3
AD Russell SP Narine HH Pandya
bowling_sr 17.7 19.7 20.3
batting_sr 182.3 164.3 159.3
Allrounder's Data
batting_sr bowling_sr
Wicketkeeper :
• Should have been played more than 2 ipl seasons.
• Having batting strike rate of 125+ .
• Having bowling economy rate < 10.
• Having good fielding rate.
Additional Questions for Final Assessment :
--CREATING Deliveries TABLE :
CREATE TABLE Deliveries
(id int,inning int,over int,ball int,batsman char(50),non_striker char(50),bowler char(50),batsman_runs int,extra_runs int,total_runs
int,is_wicket int,dismissal_kind char(50),player_dismissed char(50),fielder char(50),extras_type char(50),batting_team
varchar(50),bowling_team varchar(50) );
--COPYING CSV FILE :
COPY Deliveries FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_Ball.csv' DELIMITER ',' CSV HEADER;
SELECT * FROM Deliveries;
--CREATING TABLE OF MATCHES DATA :
CREATE TABLE Matches
(id int,city char(50),match_date varchar(50),player_of_match char(50),venue varchar(255),neutral_venue varchar(255),team1
varchar(100),team2 varchar(100),toss_winner varchar(100),toss_decision char(50),winner varchar(100),result varchar(50),result_margin
int,eliminator char(10),method varchar(50),umpire1 char(50),umpire2 char(50) );
--COPYING CSV FILE :
COPY Matches FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_matches.csv' DELIMITER ',' CSV HEADER;
--ALTER THE DATATYPE OF match_date COLUMN TO DATE DATATYPE :
ALTER TABLE Matches ALTER COLUMN match_date TYPE DATE USING to_date(match_date,'DD-MM-YYYY’);
select * from Matches;
1. Get the count of cities that have hosted an IPL match
QUERY : select count(city) from Matches;
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) (Hint 1 : CASE
WHEN statement is used to get condition based results) (Hint 2: To convert the output data of the select statement into a table,
you can use a subquery. Create table table_name as [entire select statement].
QUERY : create table deliveries_v02 as ( select *,
case
when total_runs>=4 then 'boundary'
when total_runs=0 then 'dot'
else 'other'
end ball_result
from Deliveries )
3. Write a query to fetch the total number of boundaries and dot balls from the deliveries_v02 table.
QUERY : select ball_result,count(ball_result) from deliveries_v02 where ball_result='boundary' or
ball_result='dot' group by ball_result
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.
QUERY : select batting_team,count(ball_result) as no_of_boundaries from deliveries_v02 where
ball_result='boundary' group by batting_team order by no_of_boundaries desc
5. Write a query to fetch the total number of dot balls bowled by each team and order it in descending order of the
total number of dot balls bowled.
QUERY : select bowling_team,count(ball_result) as no_of_dot_balls from deliveries_v02 where
ball_result='dot' group by bowling_team order by no_of_dot_balls desc
6. Write a query to fetch the total number of dismissals by dismissal kinds where dismissal kind is not NA
QUERY : select dismissal_kind,count(dismissal_kind) from deliveries_v02 where not dismissal_kind='NA' group
by dismissal_kind
7. Write a query to get the top 5 bowlers who conceded maximum extra runs from the deliveries table
QUERY : select bowler,sum(extra_runs) as conceded_extra_runs from deliveries_v02 group by bowler order by
bowler desc limit 5;
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
QUERY : create table deliveries_v03 as( select a.* ,b.venue,b.match_date from deliveries_v02 as a full join
Matches as b on a.id=b.id) ;
9. Write a query to fetch the total runs scored for each venue and order it in the descending order of total runs
scored.
QUERY : select venue,sum(total_runs) as total_runs from deliveries_v03 group by venue order by venue desc ;
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.
QUERY : select distinct extract(year from match_date) as yearwise_total_run,sum(total_runs) as total_runs
from deliveries_v03 where venue='Eden Gardens' group by yearwise_total_run;

More Related Content

What's hot

What's hot (17)

Theme Quiz Journey 26.5.'20- Qazi Nazrul Islam Special
Theme Quiz Journey 26.5.'20- Qazi Nazrul Islam SpecialTheme Quiz Journey 26.5.'20- Qazi Nazrul Islam Special
Theme Quiz Journey 26.5.'20- Qazi Nazrul Islam Special
 
Curso fifa preparación física en el fútbol
Curso fifa preparación física en el fútbolCurso fifa preparación física en el fútbol
Curso fifa preparación física en el fútbol
 
Logo quiz
Logo quizLogo quiz
Logo quiz
 
The Laws of Cricket (2017 code)
The Laws of Cricket (2017 code) The Laws of Cricket (2017 code)
The Laws of Cricket (2017 code)
 
IPL
IPLIPL
IPL
 
IPL
IPLIPL
IPL
 
popular games in india
popular games in indiapopular games in india
popular games in india
 
Cricket History
Cricket HistoryCricket History
Cricket History
 
The laws of cricket (2017 code)
The laws of cricket (2017 code)The laws of cricket (2017 code)
The laws of cricket (2017 code)
 
Qayyum Report.pdf
Qayyum Report.pdfQayyum Report.pdf
Qayyum Report.pdf
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
 
Basketball
BasketballBasketball
Basketball
 
EJERCICIOS MILAN
EJERCICIOS MILANEJERCICIOS MILAN
EJERCICIOS MILAN
 
Введение в SQL
Введение в SQLВведение в SQL
Введение в SQL
 
History of cricket
History of cricket History of cricket
History of cricket
 
Tip oracle
Tip oracleTip oracle
Tip oracle
 
History of cricket in india
History of cricket in indiaHistory of cricket in india
History of cricket in india
 

Similar to This is a SQL IPL auction strategy based project help to choose best player among number of player based on their past performance.

Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...ThinkInnovation
 
Optimizing Cypher Queries in Neo4j
Optimizing Cypher Queries in Neo4jOptimizing Cypher Queries in Neo4j
Optimizing Cypher Queries in Neo4jNeo4j
 
Mignesh Birdi Assignment3.pdf
Mignesh Birdi Assignment3.pdfMignesh Birdi Assignment3.pdf
Mignesh Birdi Assignment3.pdfmigneshbirdi
 
Write a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdfWrite a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdfrozakashif85
 
How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)
How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)
How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)Paul Richards
 
Joshua navarro calculating wins above replacement and accompanying graphs
Joshua navarro   calculating wins above replacement and accompanying graphsJoshua navarro   calculating wins above replacement and accompanying graphs
Joshua navarro calculating wins above replacement and accompanying graphsJoshua Navarro
 
IPL auction q1_q2.docx
IPL auction q1_q2.docxIPL auction q1_q2.docx
IPL auction q1_q2.docxAlivaMishra4
 
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineHow to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineCitus Data
 

Similar to This is a SQL IPL auction strategy based project help to choose best player among number of player based on their past performance. (10)

Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...Unlocking New Insights Into the World of European Soccer Through the European...
Unlocking New Insights Into the World of European Soccer Through the European...
 
Optimizing Cypher Queries in Neo4j
Optimizing Cypher Queries in Neo4jOptimizing Cypher Queries in Neo4j
Optimizing Cypher Queries in Neo4j
 
IPL WIN PREDICTION.pptx
IPL WIN PREDICTION.pptxIPL WIN PREDICTION.pptx
IPL WIN PREDICTION.pptx
 
IPL WIN .pptx
IPL WIN .pptxIPL WIN .pptx
IPL WIN .pptx
 
Mignesh Birdi Assignment3.pdf
Mignesh Birdi Assignment3.pdfMignesh Birdi Assignment3.pdf
Mignesh Birdi Assignment3.pdf
 
Write a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdfWrite a class (BasketballTeam) encapsulating the concept of a tea.pdf
Write a class (BasketballTeam) encapsulating the concept of a tea.pdf
 
How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)
How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)
How to win $10m - analysing DOTA2 data in R (Sheffield R Users Group - May)
 
Joshua navarro calculating wins above replacement and accompanying graphs
Joshua navarro   calculating wins above replacement and accompanying graphsJoshua navarro   calculating wins above replacement and accompanying graphs
Joshua navarro calculating wins above replacement and accompanying graphs
 
IPL auction q1_q2.docx
IPL auction q1_q2.docxIPL auction q1_q2.docx
IPL auction q1_q2.docx
 
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri FontaineHow to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
How to write SQL queries | pgDay Paris 2019 | Dimitri Fontaine
 

Recently uploaded

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

This is a SQL IPL auction strategy based project help to choose best player among number of player based on their past performance.

  • 1. PRESENTATION ON IPL AUCTION STRATEGY CREATED BY : SUDHANSHU WALIA COURSE NAME : DATA SCIENCE INTERNSHALA TRAININGS
  • 2. CREATED IPL PLAYER DATAAS ipl_player_data FROM IPL_BALL.CSV FILE CREATE TABLE ipl_player_data (id int,inning int,over int,ball int,batsman char(50),non_striker char(50),bowler char(50),batsman_runs int, extra_runs int,total_runs int,is_wicket int,dismissal_kind char(50),player_dismissed char(50),fielder char(50), extras_type char(50),batting_team varchar(50),bowling_team varchar(50) ); --COPYING CSV FILE QUERY : COPY ipl_player_data FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_Ball.csv' DELIMITER ',' CSV HEADER; --QUERY TO RETRIEVE DATA : SELECT * FROM ipl_player_data;
  • 3. CREATED IPL MATCH DATAAS ipl_match_data FROM IPL_MATCHES.CSV FILE CREATE TABLE ipl_match_data (id int,city char(50),match_date varchar(50),player_of_match char(50),venue varchar(255),neutral_venue varchar(255), team1 varchar(100),team2 varchar(100),toss_winner varchar(100),toss_decision char(50),winner varchar(100), result varchar(50),result_margin int,eliminator char(10),method varchar(50),umpire1 char(50),umpire2 char(50) ); --COPYING CSV FILE QUERY : COPY ipl_match_data FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_matches.csv' DELIMITER ',' CSV HEADER; --ALTER THE DATATYPE OF match_date COLUMN TO DATE DATATYPE ALTER TABLE ipl_match_data ALTER COLUMN match_date TYPE DATE USING to_date(match_date,'DD-MM- YYYY’); --QUERY TO RETRIEVE DATA : select * from ipl_match_data;
  • 4. Q1:Your first priority is to get 2-3 players with high S.R who have faced at least 500 balls.And to do that you have to make a list of 10 players you want to bid in the auction so that when you try to grab them in auction you should not pay the amount greater than you have in the purse for a particular player. SELECT batsman ,cast(strike_rate as decimal(4,1)),DENSE_RANK() OVER (ORDER BY strike_rate DESC) AS player_rank FROM( SELECT batsman,CAST (player_total_runs as float)/balls_faced*100 as strike_rate FROM( SELECT batsman,sum(batsman_runs) AS player_total_runs, count(ball) AS balls_faced FROM ipl_player_data WHERE NOT extras_type ='wides' GROUP BY batsman) AS a WHERE balls_faced>500 ) AS b ORDER BY strike_rate DESC LIMIT 10; 182.3 164.3 159.3 155.4 154.7 152 151.9 150.1 149.9 149.6 AD Russell SP Narine HH Pandya V Sehwag GJ Maxwell RR Pant AB de Villiers CH Gayle KA Pollard JC Buttler Batsman Strike_Rate
  • 5. Q2: Now you need to get 2-3 players with good Average who have played more than 2 ipl seasons. And to do that you have to make a list of 10 players you want to bid in the auction so that when you try to grab them in auction you should not pay the amount greater than you have in the purse for a particular player SELECT batsman,player_average,DENSE_RANK() OVER (ORDER BY player_average DESC) FROM ( SELECT *,cast(AVG(total_runs/dismissed_no) as decimal(3,1) )AS player_average FROM( select batsman,sum(batsman_runs) as total_runs, sum(is_wicket) as dismissed_no,count(distinct extract(year from match_date)) as played_years from (SELECT a.batsman, a.batsman_runs, a.is_wicket, b.match_date FROM ipl_player_data as a full join ipl_match_data as b on a.id=b.id ) AS c GROUP BY batsman ) as d group by batsman,total_runs,dismissed_no, played_years having dismissed_no>=1 and played_years>2 ORDER BY player_average DESC) as e LIMIT 10; 88 42 42 41 41 41 41 39 39 38 Batsman With Good Average
  • 6. Q3: Now you need to get 2-3 Hard-hitting players who have scored most runs in boundaries and have played more the 2 ipl season. To do that you have to make a list of 10 players you want to bid in the auction so that when you try to grab them in auction you should not pay the amount greater than you have in the purse for a particular player. select batsman,cast(boundary_percentage as decimal(3,1)),DENSE_RANK() OVER (ORDER BY boundary_percentage DESC) from( select *,(cast(boundary_runs as float)/total_runs*100) as boundary_percentage from ( SELECT batsman,total_runs,SUM(batsman_runs) AS boundary_runs, COUNT(batsman_runs) AS boundaries_total,count(distinct extract(year from match_date)) as played_years from (SELECT a.batsman,a.batsman_runs,SUM(a.batsman_runs) OVER (PARTITION BY a.batsman) as total_runs, b.match_date FROM ipl_player_data as a full join ipl_match_data as b on a.id=b.id ) as c WHERE batsman_runs=4 or batsman_runs=6 group by total_runs,batsman order by boundaries_total DESC ) as d where played_years>2 order by boundary_percentage desc ) as e limit 10 ; 81.2 78.7 76.1 75.1 74.2 73.1 72.9 72.9 72.7 72.4 Player with most boundary_percentage
  • 7. Q4: Your first priority is to get 2-3 bowlers with good economy who have bowled at least 500 balls in IPL so far.To do that you have to make a list of 10 players you want to bid in the auction so that when you try to grab them in auction you should not pay the amount greater than you have in the purse for a particular player select bowler,cast(economy as decimal(2,1)),DENSE_RANK() OVER (ORDER BY economy asc) from( select *,conceded_runs/cast(bowled_overs as decimal) as economy from( select bowler,conceded_runs,bowled_balls,count(ball)/6||'.'||count(ball)%6 as bowled_overs from( SELECT bowler,ball, sum(total_runs) over (partition by bowler) as conceded_runs, count(ball) over (partition by bowler) as bowled_balls,over from ipl_player_data ) as a where bowled_balls>500 group by bowler,conceded_runs,bowled_balls) as b ) as c limit 10 ; 6.3 6.7 6.7 6.8 6.8 6.8 6.9 6.9 6.9 7 Rashid Khan A Kumble M Muralitharan DW Steyn R Ashwin SP Narine DL Vettori Washington Sundar J Botha R Tewatia Bowler's Economy
  • 8. Q5: Now you need to get 2-3 bowlers with the best strike rate and who have bowled at least 500 balls in IPL so far.To do that you have to make a list of 10 players you want to bid in the auction so that when you try to grab them in auction you should not pay the amount greater than you have in the purse for a particular player select bowler,cast(strike_rate as decimal(3,1)),DENSE_RANK() OVER (ORDER BY strike_rate) from ( select *,cast(total_balls as float)/wicket_taken as strike_rate from ( select bowler,total_balls,sum(is_wicket) as wicket_taken from ( select bowler,is_wicket,count(ball) over (partition by bowler) as total_balls from ipl_player_data ) as a where is_wicket>0 and total_balls>500 group by bowler,total_balls )as b order by strike_rate asc limit 10 )as c 12.7 14 14.3 15.7 15.8 15.8 16.3 16.3 16.4 16.7 K Rabada DE Bollinger AJ Tye MA Starc SL Malinga Imran Tahir DJ Bravo A Nehra S Aravind KK Cooper Bowler's Strike Rate
  • 9. Q6: Now you need to get 2-3 All_rounders with the best batting as well as bowling strike rate and who have faced at least 500 balls in IPL so far and have bowled minimum 300 balls.To do that you have to make a list of 10 players you want to bid in the auction so that when you try to grab them in auction you should not pay the amount greater than you have in the purse for a particular player. create table bats_sr as ( select batsman,cast(player_total_runs as decimal)/balls_faced*100 as batting_sr from( SELECT batsman,sum(batsman_runs) AS player_total_runs, count(ball) AS balls_faced FROM ipl_player_data WHERE NOT extras_type ='wides' GROUP BY batsman having count(ball)>500 ) as a ) create table bowl_sr as (select bowler,cast(total_balls as decimal)/wicket_taken as bowling_sr from( select bowler,total_balls,sum(is_wicket) as wicket_taken from ( select bowler,is_wicket,count(ball) over (partition by bowler) as total_balls from ipl_player_data ) as a where is_wicket>0 and total_balls>300 group by bowler,total_balls) as a ) select a.batsman as allrounder,cast(a.batting_sr as decimal(4,1)),cast(b.bowling_sr as decimal(3,1)) from bats_sr as a inner join bowl_sr as b on a.batsman=b.bowler where batting_sr>150 and bowling_sr<21 182.3 164.3 159.3 17.7 19.7 20.3 AD Russell SP Narine HH Pandya bowling_sr 17.7 19.7 20.3 batting_sr 182.3 164.3 159.3 Allrounder's Data batting_sr bowling_sr
  • 10. Wicketkeeper : • Should have been played more than 2 ipl seasons. • Having batting strike rate of 125+ . • Having bowling economy rate < 10. • Having good fielding rate.
  • 11. Additional Questions for Final Assessment : --CREATING Deliveries TABLE : CREATE TABLE Deliveries (id int,inning int,over int,ball int,batsman char(50),non_striker char(50),bowler char(50),batsman_runs int,extra_runs int,total_runs int,is_wicket int,dismissal_kind char(50),player_dismissed char(50),fielder char(50),extras_type char(50),batting_team varchar(50),bowling_team varchar(50) ); --COPYING CSV FILE : COPY Deliveries FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_Ball.csv' DELIMITER ',' CSV HEADER; SELECT * FROM Deliveries;
  • 12. --CREATING TABLE OF MATCHES DATA : CREATE TABLE Matches (id int,city char(50),match_date varchar(50),player_of_match char(50),venue varchar(255),neutral_venue varchar(255),team1 varchar(100),team2 varchar(100),toss_winner varchar(100),toss_decision char(50),winner varchar(100),result varchar(50),result_margin int,eliminator char(10),method varchar(50),umpire1 char(50),umpire2 char(50) ); --COPYING CSV FILE : COPY Matches FROM 'C:Sudhanshu WaliainternshalaSQLProjectIPL DatasetIPL_matches.csv' DELIMITER ',' CSV HEADER; --ALTER THE DATATYPE OF match_date COLUMN TO DATE DATATYPE : ALTER TABLE Matches ALTER COLUMN match_date TYPE DATE USING to_date(match_date,'DD-MM-YYYY’); select * from Matches;
  • 13. 1. Get the count of cities that have hosted an IPL match QUERY : select count(city) from Matches;
  • 14. 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) (Hint 1 : CASE WHEN statement is used to get condition based results) (Hint 2: To convert the output data of the select statement into a table, you can use a subquery. Create table table_name as [entire select statement]. QUERY : create table deliveries_v02 as ( select *, case when total_runs>=4 then 'boundary' when total_runs=0 then 'dot' else 'other' end ball_result from Deliveries )
  • 15. 3. Write a query to fetch the total number of boundaries and dot balls from the deliveries_v02 table. QUERY : select ball_result,count(ball_result) from deliveries_v02 where ball_result='boundary' or ball_result='dot' group by ball_result
  • 16. 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. QUERY : select batting_team,count(ball_result) as no_of_boundaries from deliveries_v02 where ball_result='boundary' group by batting_team order by no_of_boundaries desc
  • 17. 5. Write a query to fetch the total number of dot balls bowled by each team and order it in descending order of the total number of dot balls bowled. QUERY : select bowling_team,count(ball_result) as no_of_dot_balls from deliveries_v02 where ball_result='dot' group by bowling_team order by no_of_dot_balls desc
  • 18. 6. Write a query to fetch the total number of dismissals by dismissal kinds where dismissal kind is not NA QUERY : select dismissal_kind,count(dismissal_kind) from deliveries_v02 where not dismissal_kind='NA' group by dismissal_kind
  • 19. 7. Write a query to get the top 5 bowlers who conceded maximum extra runs from the deliveries table QUERY : select bowler,sum(extra_runs) as conceded_extra_runs from deliveries_v02 group by bowler order by bowler desc limit 5;
  • 20. 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 QUERY : create table deliveries_v03 as( select a.* ,b.venue,b.match_date from deliveries_v02 as a full join Matches as b on a.id=b.id) ;
  • 21. 9. Write a query to fetch the total runs scored for each venue and order it in the descending order of total runs scored. QUERY : select venue,sum(total_runs) as total_runs from deliveries_v03 group by venue order by venue desc ;
  • 22. 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. QUERY : select distinct extract(year from match_date) as yearwise_total_run,sum(total_runs) as total_runs from deliveries_v03 where venue='Eden Gardens' group by yearwise_total_run;