sql 大多数疯子都在IPL中击败

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 大多数疯子都在IPL中击败相关的知识,希望对你有一定的参考价值。

-- Most madiens bowled in the IPL

WITH DATA ( Match_Id , Innings_No , Over_Id , Bowler_Name , Runs_In_Over , Extra_Runs , Total_Runs)
As
(
SELECT A.Match_Id , A.Innings_No , A.Over_Id , A.Player_Name ,A.Runs_In_Over ,B.Extra_runs , A.Runs_In_Over + ISNULL(B.Extra_runs,0) As 'Runs'
	 FROM 
		( SELECT A.Match_Id , A.Innings_No , A.Over_Id , C.Player_Name ,Sum(B.Runs_Scored) As 'Runs_In_Over'
				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.Bowler = C.Player_Id 
					GROUP BY A.Match_Id , A.Innings_No , A.Over_Id , C.Player_Name
		  ) A
		  LEFT JOIN
		  ( SELECT A.Match_Id , A.Innings_No , A.Over_Id , C.Player_Name , Sum(B.Extra_Runs) As 'Extra_runs'
					FROM Ball_by_Ball A
					INNER JOIN Extra_Runs 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.Extra_Type_Id IN (2)
					GROUP BY A.Match_Id , A.Innings_No , A.Over_Id , C.Player_Name
			) B
		ON CONCAT(A.Match_Id,A.Over_Id,A.Innings_No,A.Player_Name)
									= CONCAT(B.Match_Id,B.Over_Id,B.Innings_No,B.Player_Name)
		WHERE A.Runs_In_Over + ISNULL(B.Extra_runs,0) = 0

)

SELECT Bowler_Name , COUNT(*) As 'Madiens_Bowled' 
		FROM DATA
		GROUP BY Bowler_Name
		ORDER BY Madiens_Bowled DESC ;

-- Linkedin Profile :  https://www.linkedin.com/in/harshasannareddy/

以上是关于sql 大多数疯子都在IPL中击败的主要内容,如果未能解决你的问题,请参考以下文章

sql IPL Sides拥有2008年至2016年的大多数队长

sql IPL中为大多数球队效力的球员(2008年 - 2016年)

sql IPL中最高的检票员(2008-2016)

sql IPL中三分之一的玩家(2008年 - 2016年)

sql Kedhar Jadhav Man在IPL比赛中直到2016年

sql Batsman被Harbhajan大部分时间在IPL中解雇