Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 6F4886335D1 for ; Tue, 30 Jun 2009 19:39:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 22443-01 for ; Tue, 30 Jun 2009 19:39:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from polaris.pinpointresearch.com (66-7-238-130.static-ip.telepacific.net [66.7.238.130]) by mail.postgresql.org (Postfix) with ESMTP id 661BC6333C6 for ; Tue, 30 Jun 2009 19:39:27 -0300 (ADT) Received: from [192.168.1.179] (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id 54FBAE00EC83; Tue, 30 Jun 2009 15:39:24 -0700 (PDT) Message-ID: <4A4A941C.2060604@pinpointresearch.com> Date: Tue, 30 Jun 2009 15:39:24 -0700 From: Steve Crawford User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Tena Sakai CC: pgsql-sql@postgresql.org Subject: Re: it's not NULL, then what is it? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.098 tagged_above=0 required=5 tests=AWL=0.098 X-Spam-Level: X-Archive-Number: 200906/130 X-Sequence-Number: 32735 ... > > > canon=# select count(maf) from gallo.sds_seq_reg_shw > canon-# where maf ISNULL; > count > ------- > 0 > (1 row) > I believe count will only count not-null anyway so this will always return zero. Try count(*) instead of count(maf). Here's an example: steve@[local]=> select * from barr; LOG: duration: 0.226 ms a | b ---+--- a | b c | d | e (3 rows) steve@[local]=> select coalesce(a, 'a is null'), coalesce(b, 'b is null') from barr; LOG: duration: 0.283 ms coalesce | coalesce -----------+---------- a | b c | d a is null | e (3 rows) steve@[local]=> select count(a) from barr; LOG: duration: 0.339 ms count ------- 2 (1 row) steve@[local]=> select count(*) from barr where a isnull; LOG: duration: 0.350 ms count ------- 1 (1 row)