Informatics Practices

In the table 'Student' in MySQL, if column 'Fees' contains the data (5000, 8000, 7500, NULL, 5000, 8000), what will be the output after the execution of the given query?

SELECT COUNT(DISTINCT Fees) FROM student;

SQL Queries

2 Likes

Answer

The above query will return 3 as the output.

Explanation

The query SELECT COUNT(DISTINCT Fees) FROM student; returns 3 because it counts the unique non-null values in the Fees column of the Student table. In the given data (5000, 8000, 7500, NULL, 5000, 8000), the distinct non-null values are 5000, 8000, and 7500. The NULL value is excluded from the distinct count, resulting in a count of 3.

Answered By

1 Like


Related Questions