Monday 15 April 2013

SQL statement to find for each match -


This IPL season is the following IPL match database relation:

Player (player, name , Playwright) : This includes details of each player and team that he plays.

Team (Timid, Team name) : Includes Team ID and team name.

PlayerBet (Playarid, Mitchell, Ransacked, Timid) : In every match the player has only one line for the run-run player, if the player plays in the match.

Playerball (player, michid, wicket stack, timid) : In each match a wicket-by-player includes only one line for the player, if the player plays in the match is.

Players match details (player, michid) : Includes the names of the players who have played in the match.

Using the above tables, type a SQL statement to search for each match, the total runs scored by each team, which have played at least one match.

Note 1: The result for displaying the column (s) should be matched in output or output and only runs.

Note 2: When writing a SQL query, you must type the table name in the form of a schema name. (For example employee.projectDetails where employee schemaname and projectDetails are tablename).

I have made some assumptions based on note 1 and note 2. Note 1: You only want match and match runs, but the statement says that every team has scored, so you also need the team in the output, so in my reply, There will be run out output. Note 2: You do not specify a schema name, so I think all tables are in schema named schemaame. You have to replace it with the correct schema name.

  SELECT pb.matchid, t.teamname, SUM (pb.runsscored) schemaname.Playerbat pb as run from INNER JOIN schemaname. T.teamid = pb.teamid GROUP BY pb.matchid, t.teamname ORDER BY t.teamname, pb.matchid    

No comments:

Post a Comment