Computer Science
Write SQL commands for the following on the basis of given table STUDENT :
Table : STUDENT
StudentNo. | Class | Name | GAME | Grade1 | SUPW | Grade2 |
---|---|---|---|---|---|---|
10 | 7 | Sameer | Cricket | B | Photography | A |
11 | 8 | Sujit | Tennis | A | Gardening | C |
12 | 7 | Kamal | Swimming | B | Photography | B |
13 | 7 | Veena | Tennis | C | Cooking | A |
14 | 9 | Archana | Basket Ball | A | Literature | A |
15 | 10 | Arpit | Cricket | A | Gardening | C |
- Display the names of the students who are getting a grade 'C' in either GAME or SUPW.
- Display the different games offered in the school.
- Display the SUPW taken up by the students, whose name starts with 'A'.
Answer
1.
SELECT Name
FROM STUDENT
WHERE Grade1 = 'C' OR Grade2 = 'C' ;
Output
+-------+
| Name |
+-------+
| Sujit |
| Veena |
| Arpit |
+-------+
2.
SELECT DISTINCT GAME
FROM STUDENT ;
Output
+-------------+
| GAME |
+-------------+
| Cricket |
| Tennis |
| Swimming |
| Basket Ball |
+-------------+
3.
SELECT SUPW
FROM STUDENT
WHERE Name LIKE 'A%' ;
Output
+------------+
| SUPW |
+------------+
| Literature |
| Gardening |
+------------+
Related Questions
Write a query on the customers table whose output will exclude all customers with a rating <= 100, unless they are located in Shimla.
Write a query that selects all orders (Order table) except those with zeros or NULLs in the amt field.
Write SQL commands for the following on the basis of given table SPORTS :
Table : SPORTS
StudentNo. Class Name Game1 Grade1 Game2 Grade2 10 7 Sameer Cricket B Swimming A 11 8 Sujit Tennis A Skating C 12 7 Kamal Swimming B Football B 13 7 Venna Tennis C Tennis A 14 9 Archana Basketball A Cricket A 15 10 Arpit Cricket A Athletics C - Display the names of the students who have grade 'C' in either Game1 or Game2 or both.
- Display the names of the students who have same game for both Game1 and Game2.
- Display the games taken up by the students, whose name starts with 'A'.
Write SQL commands for the following on the basis of given table CLUB :
Table : CLUB
COACH_ID COACHNAME AGE SPORTS PAY SEX DATOFAPP 1 KUKREJA 35 KARATE 1000 M 1996-03-27 2 RAVINA 34 KARATE 1200 F 1998-01-20 3 KARAN 34 SQUASH 2000 M 1998-02-19 4 TARUN 33 BASKETBALL 1500 M 1998-01-01 5 ZUBIN 36 SWIMMING 750 M 1998-01-12 6 KETAKI 36 SWIMMING 800 F 1998-02-24 7 ANKITA 39 SQUASH 2200 F 1998-02-20 8 ZAREEN 37 KARATE 1100 F 1998-02-22 9 KUSH 41 SWIMMING 900 M 1998-01-13 10 SHAILYA 37 BASKETBALL 1700 M 1998-02-19 - To show all information about the swimming coaches in the club.
- To list names of all coaches with their date of appointment (DATOFAPP) in descending order.
- To display a report, showing coachname, pay, age and bonus (15% of pay) for all the coaches.