Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

Consider the table CLUB given below and write the output of the SQL queries that follow.

Question 27 CBSE Sample Question Paper 2024 Boards - Teachoo.PNG

(i) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;

Answer

Answer by student

The output of the SQL query is:

Output of the SQL query SELECT COUNT(DISTINCT SPORTS) FROM CLUB - Teachoo.png

Detailed answer by teachoo

  • The given SQL query is a SELECT statement that retrieves data from the table CLUB .
  • The COUNT() function is used to count the number of rows that match a specified condition. In this case, the condition is DISTINCT SPORTS , which means that only the unique values of the SPORTS column are counted.
  • The DISTINCT keyword is used to eliminate duplicate values from the result set. In this case, it ensures that each sport is counted only once, regardless of how many times it appears in the table.
  • The result of the query is a single value that represents the number of distinct sports in the table. To find this value, we can look at the SPORTS column and identify the unique values. They are: CHESS , CRICKET , VOLLEYBALL , and KARATE . Therefore, the number of distinct sports is 4.

So, the correct output of the SQL query is:

Output of the SQL query SELECT COUNT(DISTINCT SPORTS) FROM CLUB - Teachoo.png

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.