Received: from www.chip.org (www.chip.org [134.174.22.177]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6NJVDf35912 for ; Mon, 23 Jul 2001 15:31:14 -0400 (EDT) (envelope-from aturchin@chip.org) Received: from chip.org ([134.174.23.191]) by www.chip.org (8.11.0/8.11.0) with ESMTP id f6NJUuV19825 for ; Mon, 23 Jul 2001 15:30:56 -0400 Message-ID: <3B5C7BB4.A69E20DE@chip.org> Date: Mon, 23 Jul 2001 15:32:04 -0400 From: Alexander Turchin Organization: Children's Hospital Informatics Program X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: PostgreSQL Mailing List Subject: COUNTs don't add up Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200107/850 X-Sequence-Number: 12971 Hello all, I have a database where (I believe; the database was not made by me) one of the columns contains only two values: A or B. When I count all the rows in the database I get X; when I count the rows containing A or B in that column I get X-2; when I count the rows containing neither A nor B I get 0. Any explanation (hopefully, again, I am doing something wrong :)? The actual queries are found below. Thanks! Alex aturchin=# SELECT COUNT(*) FROM homol_loclink aturchin-# WHERE (species2 = 'Mus musculus') OR aturchin-# (species2 = 'Rattus norvegicus'); count ------- 7110 (1 row) aturchin=# SELECT COUNT(*) FROM homol_loclink; count ------- 7112 (1 row) aturchin=# SELECT COUNT(*) FROM homol_loclink aturchin-# WHERE (species2 <> 'Mus musculus') AND aturchin-# (species2 <> 'Rattus norvegicus'); count ------- 0 (1 row)