edited by
2,432 views
2 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.

1 Answer

5 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.
Position:
Show:

Related questions

2 2 votes
2 answers 2 answers
2.3k
2.3k views
set2018 asked Jul 21, 2017
2,290 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 ?
3 3 votes
1 1 answer
142
142 views
GO Classes asked Sep 3
142 views
Consider the relation$\text{Student(sid,\ name,\ age)}$where the attributes occur in the schema in the order shown.Which of the following statements correctly inserts the...
2 2 votes
1 1 answer
117
117 views
GO Classes asked Sep 3
117 views
A table contains the following attributes:$\text{code\ CHAR(6)}$$\text{name\ VARCHAR(10)}$Which of the following statements are correct?A value of $\text{code}$ has a fix...
2 2 votes
1 1 answer
448
448 views
shc asked Jan 19
448 views
In SQL-92 (which is what GATE assumes), which columns are allowed in SELECT and HAVING, when GROUP BY is present or not ?Which columns/attributes can be aggregated or non...