Skip to content

Instantly share code, notes, and snippets.

@harsha547
Last active December 17, 2016 18:43
Show Gist options
  • Select an option

  • Save harsha547/4313053c145174f9ded8fca2b3dbfe27 to your computer and use it in GitHub Desktop.

Select an option

Save harsha547/4313053c145174f9ded8fca2b3dbfe27 to your computer and use it in GitHub Desktop.
Matches won by chasing and first_batting
-- Examples Queries to run on Indian Premier League Database.
-- Matches won by chasing and first_batting
SELECT Team_Name ,
SUM( CASE WHEN Toss_Name = 'field' THEN 1 ELSE 0 END ) AS "Chasing",
SUM( CASE WHEN Toss_Name = 'bat' THEN 1 ELSE 0 END ) AS "First_Batting"
FROM
Match
INNER JOIN
Toss_Decision
ON
Match.Toss_Decide = Toss_Decision.Toss_Id
INNER JOIN
Team
ON
Match.Match_Winner = Team.Team_Id
GROUP BY GROUPING SETS ( Team_Name, ())
@harsha547
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment