Re: COUNT

From: Daniel Wickstrom <danw(at)rtp(dot)ericsson(dot)se>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: COUNT
Date: 2000-10-19 18:30:21
Message-ID: 14831.15805.753626.426101@gargle.gargle.HOWL
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>>>> "Brian" == Brian C Doyle <bcdoyle(at)mindspring(dot)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

In response to

  • Re: COUNT at 2000-10-19 18:07:15 from Brian C. Doyle

Browse pgsql-sql by date

  From Date Subject
Next Message bmccoy 2000-10-19 18:35:45 Re: COUNT
Previous Message Jie Liang 2000-10-19 18:13:57 Re: COUNT