Re: COUNT - Mailing list pgsql-sql

From Daniel Wickstrom
Subject Re: COUNT
Date
Msg-id 14831.15805.753626.426101@gargle.gargle.HOWL
Whole thread Raw
In response to Re: COUNT  ("Brian C. Doyle" <bcdoyle@mindspring.com>)
List pgsql-sql
>>>>> "Brian" == Brian C Doyle <bcdoyle@mindspring.com> writes:
   Brian> Hello, You will need to do "SELECT count(attribute) FROM   Brian> table;" or SELECT count(table.attribute);"


You need to watch this:


acspg=# create table tst (
acspg(# a integer
acspg(# );
CREATE
acspg=# insert into tst values (0);
INSERT 333481 1
acspg=# insert into tst values (null);
INSERT 333482 1
acspg=# insert into tst values (2);
INSERT 333483 1
acspg=# select count(*) from tst;count 
-------    3
(1 row)

acspg=# select count(a) from tst;count 
-------    2
(1 row)

acspg=# select count(1) from tst;count 
-------    3
(1 row)

acspg=# 


If you use the attribut name, null values won't be counted.

-Dan


pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: Re: COUNT
Next
From:
Date:
Subject: Re: COUNT