KnowledgeBoat Logo

Computer Science

Given the following table :

Table : CLUB

COACH-IDCOACHNAMEAGESPORTSDATOFAPPPAYSEX
1KUKREJA35KARATE27/03/19961000M
2RAVINA34KARATE20/01/19981200F
3KARAN34SQUASH19/02/19982000M
4TARUN33BASKETBALL01/01/19981500M
5ZUBIN36SWIMMING12/01/1998750M
6KETAKI36SWIMMING24/02/1998800F
7ANKITA39SQUASH20/02/19982200F
8ZAREEN37KARATE22/02/19981100F
9KUSH41SWIMMING13/01/1998900M
10SHAILYA37BASKETBALL19/02/19981700M

Give the output of following SQL statements :

  1. SELECT COUNT(DISTINCT SPORTS) FROM Club ;
  2. SELECT MIN(Age) FROM CLUB WHERE Sex = 'F' ;
  3. SELECT AVG(Pay) FROM CLUB WHERE Sports = 'KARATE' ;
  4. SELECT SUM(Pay) FROM CLUB WHERE Datofapp > '1998-01-31' ;

SQL Joins & Grouping

5 Likes

Answer

1.

Output
+------------------------+
| COUNT(DISTINCT SPORTS) |
+------------------------+
|                      4 |
+------------------------+
Explanation

The SQL query SELECT COUNT(DISTINCT SPORTS) FROM Club ; calculates the count of unique values in the 'SPORTS' column of the 'Club' table. This query helps us to get information about the number of sports offered by the club.

2.

Output
+----------+
| MIN(Age) |
+----------+
|       34 |
+----------+
Explanation

The SQL query SELECT MIN(Age) FROM CLUB WHERE Sex = 'F' ; retrieves the minimum Age from the 'CLUB' table where the 'Sex' column has the value 'F'. This query gives us the age of the youngest female coach in the club.

3.

Output
+-----------+
| AVG(Pay)  |
+-----------+
| 1100.0000 |
+-----------+
Explanation

The SQL query SELECT AVG(Pay) FROM CLUB WHERE Sports = 'KARATE' ; calculates the average value of the 'Pay' column from the 'CLUB' table where the 'Sports' column has the value 'KARATE'. This query helps us to get information about the average pay of karate coaches in the club.

4.

Output
+----------+
| SUM(Pay) |
+----------+
|     7800 |
+----------+
Explanation

The SQL query SELECT SUM(Pay) FROM CLUB WHERE Dateofapp > '1998-01-31'; calculates the sum of the 'Pay' column from the 'CLUB' table where the 'Dateofapp' column has a date value greater than '1998-01-31'. This query gives us the total pay of all the coaches who joined after 31/01/1998.

Answered By

2 Likes


Related Questions