edited by
1,338 views
2 votes
2 votes
Given  a column consisting of 12,19,12,13,14,NULL,NULL. What will be the answer

1.If we apply count on the column.

2.If we apply sum on the column.

3.If we apply avg on the column.

4.If we apply count(*) on the column.

Please provide the explanation whether to count null or not.
edited by

1 Answer

5 votes
5 votes
Aggregate functions ignore NULL.

1.COUNT(column) returns no of not null values . So here is 5.

2.SUM(column)  = 12+19+12+13+14 = 70

3. AVG(column) = sum of elements / no of elements( ignore NULL) = 70/5 = 14

4. COUNT(*) it returns number of not null rows of the table.
if the table has single column. COUNT(*) = 5. else COUNT(*) = 7.

Related questions

2 votes
2 votes
2 answers
1
set2018 asked Jul 21, 2017
1,423 views
Can we apply min and max (aggregate function in sql) on strings and date datatype ?Query :SELECT max(Name) FROM EMPLOYEEwhat will be the result ?
0 votes
0 votes
1 answer
2