Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id AAA80349 for ; Sat, 23 Oct 1999 00:56:45 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id AAA00801; Sat, 23 Oct 1999 00:55:35 -0400 (EDT) To: guenther@laokoon.IN-Berlin.DE (Christian Guenther) cc: pgsql-sql@hub.org Subject: Re: [SQL] sum-function In-reply-to: Your message of Sat, 23 Oct 1999 01:34:51 +0200 (CEST) <199910222334.BAA11750@laokoon.bug.net> Date: Sat, 23 Oct 1999 00:55:35 -0400 Message-ID: <799.940654535@sss.pgh.pa.us> From: Tom Lane guenther@laokoon.IN-Berlin.DE (Christian Guenther) writes: > udmsearch=> select sum( dict.word = 'mysql') from dict\g > ERROR: Unable to select an aggregate function sum(bool) > What does the ERROR mean. The '=' operator produces a boolean (true/false) result, but sum() wants a numeric input. Postgres is a strongly-typed system, so it doesn't think booleans are interchangeable with numerics. It's been suggested several times that Postgres should provide a standard conversion function that converts boolean values to 0/1 numeric values, but no one's gotten around to making one. In the meantime you could get the result that I think you want with something like select sum(case when dict.word = 'mysql' then 1 else 0 end) ... regards, tom lane