Tournament
Tournament
CREATE table Team (Team_id integer PRIMARY KEY, T_name varchar(20), City
varchar(20), Coach varchar(20), Player_Count integer, Captain varchar(20));
CREATE table Player (Player_id integer PRIMARY KEY, P_name varchar(20), Age integer,
Team_id integer, FOREIGN KEY(Team_id) REFERENCES Team(Team_id));
CREATE table Stadium (Stadium_id integer PRIMARY KEY, S_name varchar(20), Area
varchar(20), City varchar(20), Pincode varchar(20));
INSERT into Stadium values (100, “Chinnaswamy”, “Raj Nagar”, “Bangalore”, 560001);
INSERT into Stadium values (200, “Wankhede”, “Church Gate”, “Mumbai”, 400020);
INSERT into Stadium values (300, “Eden Gardens”, “BBD Baagh”, “Kolkata”, 700021);
INSERT into Stadium values (400, “JN Stadium”, “Pragati Vihar”, “Delhi”, 110003);
INSERT into Stadium values (500, “MA Chi”, “Victoria Road”, “Chennai”, 600005);
CREATE table Matches (Match_id integer PRIMARY KEY, Team1 integer, Team2 integer,
Stadium_id integer, Played_date date, Play_time time, Team_won integer, Team_loss integer,
Man_of_the_match integer, FOREIGN KEY(Stadium_id) References Stadium(Stadium_id));
INSERT into Matches value (1, 71, 79, 100, '2023-06-27', '20:00:00', 71, 79, '1');
INSERT into Matches value (2, 73, 75, 300, '2023-06-29', '20:00:00', 75, 73, '1');
INSERT into Matches value (3, 77, 73, 400, '2023-07-01', '20:00:00', 73, 71, '3');
INSERT into Matches value (4, 75, 77, 500, '2023-07-10', '20:00:00', 79, 75, '5');
INSERT into Matches value (5, 71, 75, 100, '2023-07-12', '20:00:00', 71, 75, '5');
Player_id Phone_no
Player_id Phone_no
1 9988774455
3 9874563210
5 9992243330
7 9994421110
9 9877453210
1. Display the youngest player (in terms of age) name, team_name, age in which he
belongs of the tournament.
SELECT P.P_name, T.T_Name, P.Age from Player P, Team T WHERE P.Team_id =T.Team_i
d AND P.Player_id in (SELECT Player_id from Player WHERE Age=(SELECT min(Age) fr
om Player))
2. List the details of stadium where the maximum number of matches are played.
3. List the details of the player who is not the captain but got Man of The Match
award atleast in two matches.
SELECT * from Player WHERE Player_id not in (SELECT Captain from team) and Player_id
in (SELECT man_of_the_match from matches GROUP By man_of_the_match HAVING CO
UNT(man_of_the_match) = 2)
SELECT T.* FROM Team T JOIN ( SELECT M.Team_won, COUNT(*) AS id_count FROM
Matches M GROUP BY M.Team_won ) AS Subquery ON T.Team_id = Subquery.Team_won
WHERE Subquery.id_count = ( SELECT MAX(id_count) FROM ( SELECT COUNT(Team_
won) AS id_count FROM Matches GROUP BY Team_won ) AS n )
5. Display the team’s name where all its won matches played in same stadium.
SELECT T.T_name FROM Team T WHERE NOT EXISTS ( SELECT * FROM Matches M
WHERE M.Stadium_id = (SELECT Stadium_id FROM Stadium WHERE S_name = 'Chinnas
wamy') AND T.Team_id = M.Team_Loss );
T_name
CSK
MI
SRH
RR