Aggregate functions in the statistics of a ~, are often common gray. But there's a little bit to be aware of.
Create Table#Tmp (AintBint )Insert into#Tmp (A, B)Values(1,NULL),(NULL,NULL),(NULL,3),(2,4)Select * from#Tmpa b----------- -----------1 NULLNULL NULLNULL 32 4
Here I'll simply try using the count and Sum and AVG 3 most commonly used functions. This usage is very simple, just pay attention to the behavior of the null value in this area.
Select COUNT(*),COUNT(a),COUNT(A+b from#TmpSelect sum(a),sum(b),sum(A+b from#TmpSelect avg(a),avg(b*1.0),avg(A+b from#Tmp----------- ----------- -----------4 2 1 ----------- ----------- -----------3 7 6 ----------- --------------------------------------- -----------1 3.500000 6
Note that when the row data contains a null value, the row data is filtered. COUNT (*) excepted
(*^__^*) hehe ...
Use of aggregate functions