[Assignments] Simple Queries in SQL — Chapter 12 Assignments (Q/A)
Solution:
SELECT Name FROM SPORTS
WHERE Grade1 = 'C' OR Grade2 = 'C';SELECT Name FROM SPORTS
WHERE Game1 = Game2;SELECT Game1, Game2
FROM SPORTS
WHERE Name LIKE "A%";
Table of Contents
12. Write SQL commands for the following on the basis of given table CLUB:
COACH_ID | COACHNAME | AGE | SPORTS | DATOFAPP | PAY | SEX |
---|---|---|---|---|---|---|
1 | KUKREJA | 35 | KARATE | 27.3.96 | 1000 | M |
2 | RAVINA | 34 | KARATE | 20.1.98 | 1200 | F |
3 | KARAN | 34 | SQUASH | 19.2.98 | 2000 | M |
4 | TARUN | 33 | BASKETBALL | 1.1.98 | 1500 | M |
5 | ZUBIN | 36 | SWIMMING | 12.1.98 | 750 | M |
6 | KETAKI | 36 | SWIMMING | 24.2.98 | 800 | F |
7 | ANKITA | 39 | SQUASH | 20.2.98 | 2200 | F |
8 | ZAREEN | 37 | KARATE | 22.2.98 | 1100 | F |
9 | KUSH | 41 | SWIMMING | 13.1.98 | 900 | M |
10 | SHAILYA | 37 | BASKETBALL | 19.2.98 | 1700 | M |
- 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.
Solution:
SELECT * FROM CLUB
WHERE SPORTS="SWIMMING";SELECT COACHNAME, DATOFAPP
FROM CLUB
ORDER BY DATOFAPP DESC;SELECT COACHNAME, PAY, AGE, 0.15*PAY AS BONUS
FROM CLUB;