Skip to content

Instantly share code, notes, and snippets.

@harsha547
harsha547 / IPL_22.SQL
Created April 16, 2017 15:16
Highest wicket takers in IPL (2008-2016)
-- Highest wicket takers in IPL (2008-2016)
SELECT C.Player_Name , COUNT(*) As 'Wickets_Taken'
FROM Ball_by_Ball A
INNER JOIN Wicket_Taken B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id ,B.Ball_Id ,B.Innings_No)
INNER JOIN Player C
ON A.Bowler = C.Player_Id
WHERE B.Kind_Out NOT IN (3,5,9)
@harsha547
harsha547 / IPL_21.SQL
Created April 16, 2017 15:13
Five wicket hauls in IPL (2008-2016)
-- Five wicket hauls in IPL (2008-2016)
SELECT A.Match_Id,C.Player_Name , COUNT(*) As 'Wickets_Taken'
FROM Ball_by_Ball A
INNER JOIN Wicket_Taken B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id ,B.Ball_Id ,B.Innings_No)
INNER JOIN Player C
ON A.Bowler = C.Player_Id
WHERE B.Kind_Out NOT IN (3,5,9)
@harsha547
harsha547 / IPL_20.SQL
Created April 16, 2017 15:11
Bowlers with most Five wicket hauls in IPL (2008-2016)
-- Bowlers with most Five wicket hauls in IPL (2008-2016)
WITH CTE(Match_Id, Player_Name , Wickets_taken)
As
(
SELECT A.Match_Id,C.Player_Name , COUNT(*) As 'Wickets_Taken'
FROM Ball_by_Ball A
INNER JOIN Wicket_Taken B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id ,B.Ball_Id ,B.Innings_No)
INNER JOIN Player C
@harsha547
harsha547 / IPL_19.SQL
Created April 16, 2017 15:07
Players involved in most IPL Match Victories
-- Players involved in most IPL Match Victories
SELECT C.Player_Name , COUNT(*) As 'Most_IPL_Victories'
FROM Match A
INNER JOIN Player_Match B
ON CONCAT(A.Match_Id,A.Match_Winner)
= CONCAT(B.Match_Id,B.Team_Id)
INNER JOIN Player C
ON B.Player_Id = C.Player_Id
GROUP BY C.Player_Name
@harsha547
harsha547 / IPL_18.SQL
Created April 10, 2017 22:03
Metrics in Indian Premier League ( 2008 - 2016 )
-- Important metrics in IPL ( 2008 - 2016 )
SELECT 'Matches' As Dimension , COUNT(*) As 'Measure'
FROM Match
UNION ALL
SELECT 'Extra_Runs' As Dimension , SUM(Extra_Runs.Extra_Runs) As 'Measure'
FROM Extra_Runs
@harsha547
harsha547 / IPL_17.SQL
Created April 10, 2017 21:18
Players with Most Sixes's in IPL ( 2008 - 2016 )
-- Players with Most Sixes's in IPL ( 2008 - 2016 )
SELECT C.Player_Name ,COUNT(*) As 'Sixes'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id,B.Ball_Id,B.Innings_No)
INNER JOIN Player C
ON A.Striker = C.Player_Id
INNER JOIN Match D
@harsha547
harsha547 / IPL_16.SQL
Created April 10, 2017 21:15
Players with Most Dot_Ball's in IPL ( 2008 - 2016 )
-- Players with Most Dot_Ball's in IPL ( 2008 - 2016 )
SELECT C.Player_Name ,COUNT(*) As 'Dot_Ball'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id,B.Ball_Id,B.Innings_No)
INNER JOIN Player C
ON A.Striker = C.Player_Id
INNER JOIN Match D
@harsha547
harsha547 / IPL_15.SQL
Created April 10, 2017 21:11
Players with Most Single's in IPL ( 2008 - 2016 )
-- Players with Most Single's in IPL ( 2008 - 2016 )
SELECT C.Player_Name ,COUNT(*) As 'Single'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id,B.Ball_Id,B.Innings_No)
INNER JOIN Player C
ON A.Striker = C.Player_Id
INNER JOIN Match D
@harsha547
harsha547 / IPL_14.SQL
Created April 10, 2017 21:09
Players with Most three's in IPL ( 2008 - 2016 )
-- Players with Most three's in IPL ( 2008 - 2016 )
SELECT C.Player_Name ,COUNT(*) As 'Three'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id,B.Ball_Id,B.Innings_No)
INNER JOIN Player C
ON A.Striker = C.Player_Id
INNER JOIN Match D
@harsha547
harsha547 / IPL_13.SQL
Created April 10, 2017 21:06
Players with Most two's in IPL ( 2008 - 2016 )
-- Players with Most two's in IPL ( 2008 - 2016 )
SELECT C.Player_Name ,COUNT(*) As ' Two'
FROM Ball_by_Ball A
INNER JOIN Batsman_Scored B
ON CONCAT(A.Match_Id,A.Over_Id,A.Ball_Id,A.Innings_No)
= CONCAT(B.Match_Id,B.Over_Id,B.Ball_Id,B.Innings_No)
INNER JOIN Player C
ON A.Striker = C.Player_Id
INNER JOIN Match D