Created
December 17, 2016 19:04
-
-
Save harsha547/6f109bb460f9e367fd64cce4b7ec0609 to your computer and use it in GitHub Desktop.
Season wise top 5 run getters in Indian Premier League
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- You can pass the Season_Id Value in the Season_Id Variable ( Indian Premier League Database ) | |
-- Either you can create the Table-Valued-Function to pass the Season_ID value to the function. | |
SELECT TOP 5 Player_Name , SUM(Runs_Scored) AS Total_Runs | |
FROM Batsman_Scored BS | |
INNER JOIN | |
Ball_by_Ball Ball | |
ON CONCAT(BS.Match_Id,BS.Over_Id,BS.Ball_Id,BS.Innings_No) | |
= CONCAT(Ball.Match_Id,Ball.Over_Id,Ball.Ball_Id,Ball.Innings_No) | |
INNER JOIN Player B | |
ON Ball.Striker = B.Player_Id | |
WHERE Concat(BS.Match_Id,BS.Over_Id,BS.Ball_Id,BS.Innings_No) | |
IN ( SELECT Concat(Ball.Match_Id,Ball.Over_Id,Ball.Ball_Id,Ball.Innings_No) | |
FROM Ball_by_Ball Ball | |
WHERE Match_Id IN | |
( SELECT Match_Id | |
FROM Match | |
WHERE Season_Id = 9 | |
) | |
) | |
GROUP BY Player_Name | |
ORDER BY Total_runs DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution 👍