Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

mysql> select * from player;

+-----+-----------------+------------+------+------+
| pid | pname | pstate | tid | pamt |
+-----+-----------------+------------+------+------+
| 1 | Sachin | Maharastra | 101 | 10 |
| 2 | Rahul dravid | Karnataka | 100 | 10 |
| 3 | Anil Kumble | Karnataka | 100 | 9 |
| 4 | Sowrav Ganguly | Westbengal | 103 | 10 |
| 5 | Dhoni | Jharkand | 102 | 8 |
| 6 | Virat kohli | Delhi | 103 | 7 |
| 7 | Balaji | Tamilnadu | 102 | 7 |
| 8 | Rohith sharma | Maharastra | 100 | 7 |
| 9 | Yuvaraj Sing | Chandigarh | 101 | 6 |
| 10 | Nehra | Delhi | 103 | 6 |
| 11 | Gowtham Gambhir | Delhi | 102 | 6 |
| 12 | Sewag | Delhi | 102 | 10 |
| 13 | Harbhajan Sing | Punjab | 101 | 8 |
| 14 | Sreeshanth | Kerala | 100 | 6 |
| 15 | Zaheer khan | Maharastra | 103 | 7 |
| 16 | Javagal Srinath | Karnataka | 101 | 9 |
| 17 | abc | tnadu | 105 | 8 |
+-----+-----------------+------------+------+------+
17 rows in set (0.03 sec)

mysql> select * from stadium;


+------+---------------+------------+
| sid | sname | sstate |
+------+---------------+------------+
| 1000 | Wankhede | Maharastra |
| 1001 | Chinnaswamy | Karnataka |
| 1002 | Narendra Modi | Gujarath |
| 1003 | Eden Garden | Westbengal |
+------+---------------+------------+
4 rows in set (0.01 sec)

mysql> select * from matches;


+-----+------+------+------------+------+------+------+
| mid | t1id | t2id | sdate | wtid | mpid | sid |
+-----+------+------+------------+------+------+------+
| 50 | 100 | 101 | 2024-04-01 | 100 | 2 | 1000 |
| 51 | 101 | 102 | 2024-04-02 | 101 | 1 | 1002 |
| 52 | 102 | 103 | 2024-04-03 | 102 | 11 | 1003 |
| 53 | 103 | 100 | 2024-04-04 | 100 | 14 | 1003 |
| 54 | 101 | 102 | 2024-04-05 | 101 | 13 | 1001 |
| 55 | 103 | 100 | 2024-04-06 | 100 | 8 | 1002 |
| 56 | 101 | 103 | 2024-04-07 | 103 | 10 | 1000 |
| 57 | 100 | 102 | 2024-04-08 | 100 | 3 | 1002 |
| 58 | 101 | 103 | 2024-04-09 | 101 | 9 | 1002 |
| 59 | 102 | 100 | 2024-04-10 | 100 | 14 | 1003 |
| 60 | 100 | 101 | 2024-04-11 | 100 | 2 | 1001 |
| 61 | 100 | 101 | 2024-05-24 | 100 | 2 | 1001 |
| 62 | 100 | 105 | 2024-05-25 | 100 | 2 | 1002 |
| 63 | 101 | 105 | 2024-05-26 | 101 | 1 | 1003 |
| 64 | 101 | 105 | 2024-05-27 | 105 | 17 | 1002 |
| 65 | 100 | 101 | 2024-05-01 | 100 | 2 | 1003 |
| 66 | 100 | 102 | 2024-04-30 | 100 | 2 | 1003 |
+-----+------+------+------------+------+------+------+
17 rows in set (0.00 sec)

select t.tid,count(mid)win from team t,matches m where t.tid=m.wtid group


by wtid;
+-----+-----+
| tid | win |
+-----+-----+
| 100 | 10 |
| 101 | 4 |
| 102 | 1 |
| 103 | 1 |
| 105 | 1 |
+-----+-----+
5 rows in set (0.00 sec)

create view kavya as(select t.tid,count(mid)win from team t,matches m


where t.tid=m.wtid group by wtid);
Query OK, 0 rows affected (0.05 sec)

mysql> select * from kavya;


+-----+-----+
| tid | win |
+-----+-----+
| 100 | 10 |
| 101 | 4 |
| 102 | 1 |
| 103 | 1 |
| 105 | 1 |
+-----+-----+
5 rows in set (0.00 sec)

mysql> select t.tid,count(mid)played from team t,matches m where


m.t1id=t.tid or m.t2id=t.tid group by(t.tid);
+-----+--------+
| tid | played |
+-----+--------+
| 100 | 10 |
| 101 | 10 |
| 102 | 6 |
| 103 | 5 |
| 105 | 3 |
+-----+--------+
create view suchitra as( select t.tid,count(mid)played from team t,matches
m where m.t1id=t.tid or m.t2id=t.tid group by(t.tid));
Query OK, 0 rows affected (0.05 sec)

mysql> select * from suchitra;


+-----+--------+
| tid | played |
+-----+--------+
| 100 | 10 |
| 101 | 10 |
| 102 | 6 |
| 103 | 5 |
| 105 | 3 |
+-----+--------+
5 rows in set (0.00 sec)

mysql> select s.tid,t.tname,s.played,k.win from suchitra s,kavya k,team t


where s.tid=k.tid and s.tid=t.tid;
+-----+-------+--------+-----+
| tid | tname | played | win |
+-----+-------+--------+-----+
| 100 | RCB | 10 | 10 |
| 101 | MI | 10 | 4 |
| 102 | DC | 6 | 1 |
| 103 | KKR | 5 | 1 |
| 105 | csk | 3 | 1 |
+-----+-------+--------+-----+
5 rows in set (0.00 sec)

create view suman as(select s.tid,t.tname,s.played,k.win from suchitra


s,kavya k,team t where s.tid=k.tid and s.tid=t.tid);
Query OK, 0 rows affected (0.06 sec)

mysql> select * from suman;


+-----+-------+--------+-----+
| tid | tname | played | win |
+-----+-------+--------+-----+
| 100 | RCB | 10 | 10 |
| 101 | MI | 10 | 4 |
| 102 | DC | 6 | 1 |
| 103 | KKR | 5 | 1 |
| 105 | csk | 3 | 1 |
+-----+-------+--------+-----+
5 rows in set (0.00 sec)

//QUESTION--Display the team name who never lost any match

select tid,tname from suman s where s.played=s.win;


+-----+-------+
| tid | tname |
+-----+-------+
| 100 | RCB |
+-----+-------+
1 row in set (0.00 sec)

//QUESTION--Display the team who Loss more than 2 matches


select tid,tname from suman s where (s.played-s.win)>2;
+-----+-------+
| tid | tname |
+-----+-------+
| 101 | MI |
| 102 | DC |
| 103 | KKR |
+-----+-------+

//Question --Display the team who win atleast 5 matches

mysql> select tid,tname from suman s where (s.played-s.win)>=5;


+-----+-------+
| tid | tname |
+-----+-------+
| 101 | MI |
| 102 | DC |
+-----+-------+
2 rows in set (0.00 sec)

You might also like