Skip to content

Instantly share code, notes, and snippets.

select season_year,
Fours,
Sixes,
sum(fours*4+Sixes*6) as total_runs_in_boundries
from (SELECT season.season_year,
Sum (CASE
WHEN batsman_scored.runs_scored = 4 THEN 1
ELSE 0
END) AS 'Fours',
Sum (CASE
select season_year,
Fours,
Sixes,
[Country_Name],
sum(fours*4+Sixes*6) as total_runs_in_boundries
from (SELECT season.season_year,country.Country_Name,
Sum (CASE
WHEN batsman_scored.runs_scored = 4 THEN 1
ELSE 0
END) AS 'Fours',
select a.Match_Id,c.Player_Name,e.Season_Year,sum([Runs_Scored]) as [Runs Scored]
from [dbo].[Ball_by_Ball] a
inner join [dbo].[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 on a.Match_Id=d.Match_Id
inner join Season e on d.Season_Id=e.Season_Id
group by a.Match_Id,c.Player_Name,e.Season_Year
order by 4 desc
select f.Country_Name ,e.Season_Year,sum([Runs_Scored]) as [Runs Scored]
from [dbo].[Ball_by_Ball] a
inner join [dbo].[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 on a.Match_Id=d.Match_Id
inner join Season e on d.Season_Id=e.Season_Id
inner join Country f on f.Country_Id=c.Country_Name
select v.Venue_Name, sum(case when([Runs_Scored]=6) then 1 else 0 end) Sixes,count(distinct m.Match_Id) Matches,sum(case when([Runs_Scored]=6) then 1 else 0 end)/count(distinct m.Match_Id) Sixes_Per_Match
from [dbo].[Batsman_Scored] b
inner join Match m on b.Match_Id=m.Match_Id
inner join Venue v on v.Venue_Id=m.Venue_Id
group by v.Venue_Name
order by 2 desc
select v.Venue_Name,
sum(case when([Runs_Scored]=4) then 1 else 0 end) Fours,
count(distinct m.Match_Id) Matches,
sum(case when([Runs_Scored]=4) then 1 else 0 end)/count(distinct m.Match_Id) Fours_Per_Match
from [dbo].[Batsman_Scored] b
inner join Match m on b.Match_Id=m.Match_Id
inner join Venue v on v.Venue_Id=m.Venue_Id
group by v.Venue_Name
order by 2 desc
/****** Script for Top Players with Highest Stike Rates in the middle Overs(7-16) ******/
SELECT
c.Player_Name as Batsman,
sum([Runs_Scored]) [Runs Scored],
count(concat(a.Over_Id,a.Ball_Id)) [Balls faced],
case when (sum([Runs_Scored])<>0) then cast (sum([Runs_Scored])/cast(count(concat(a.Over_Id,a.Ball_Id))as float)as float)*100 else 0 end as Strike_rate
FROM [IPL].[dbo].[Ball_by_Ball] a
inner join [dbo].[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)
Here is URL of My Tableau Public Profile-->>>> https://public.tableau.com/profile/raghunath1816#!/
I have developed some Reports on IPL Data using Tableau