KnowledgeBoat Logo
LoginJOIN NOW

Computer Science

Write SQL commands for the following on the basis of given table SPORTS :

Table : SPORTS

StudentNo.ClassNameGame1Grade1Game2Grade2
107SameerCricketBSwimmingA
118SujitTennisASkatingC
127KamalSwimmingBFootballB
137VennaTennisCTennisA
149ArchanaBasketballACricketA
1510ArpitCricketAAthleticsC
  1. Display the names of the students who have grade 'C' in either Game1 or Game2 or both.
  2. Display the names of the students who have same game for both Game1 and Game2.
  3. Display the games taken up by the students, whose name starts with 'A'.

SQL Queries

24 Likes

Answer

1.

SELECT Name
FROM SPORTS
WHERE Grade1 = 'C' OR Grade2 = 'C' ;
Output
+-------+
| Name  |
+-------+
| Sujit |
| Venna |
| Arpit |
+-------+

2.

SELECT Name
FROM SPORTS
WHERE Game1 = Game2 ;
Output
+-------+
| Name  |
+-------+
| Venna |
+-------+

3.

SELECT Game1, Game2
FROM SPORTS
WHERE Name LIKE 'A%' ;
Output
+------------+-----------+
| Game1      | Game2     |
+------------+-----------+
| Basketball | Cricket   |
| Cricket    | Athletics |
+------------+-----------+

Answered By

11 Likes


Related Questions