30 Eylül 2011 Cuma

Count(*) Count(1) Count(Kolon_adi)

SELECT

       COUNT (*) CountYildiz_NulldaOlsaSayar,

       COUNT (1) Count1_Nulldahil1KabulEdpSayr,

       COUNT (D.TRANSIT_TASIMA_TIPI_ID) CountAlanAdi_NullariSaymaz,

       COUNT (DISTINCT D.TRANSIT_TASIMA_TIPI_ID) CntDistinct_NulldnFrkliKacAdt

  FROM dok_konsimento d

 

 

 

The parameter to the COUNT function is an expression that is to be evaluated for each row. The COUNT function returns the number of rows for which the expression evaluates to a non-null value. ( * is a special expression that is not evaluated, it simply returns the number of rows.)

 

There are two additional modifiers for the expression: ALL and DISTINCT. These determine whether duplicates are discarded. Since ALL is the default, your example is the same as count(ALL 1), which means that duplicates are retained.

Since the expression "1" evaluates to non-null for every row, and since you are not removing duplicates, COUNT(1) should always return the same number as COUNT(*).

Hiç yorum yok:

Yorum Gönder