Re: How to force Postgres to calculate MAX(boolean) - Mailing list pgsql-general

From Christopher Browne
Subject Re: How to force Postgres to calculate MAX(boolean)
Date
Msg-id m3pstupmog.fsf@mobile.int.cbbrowne.com
Whole thread Raw
In response to How to force Postgres to calculate MAX(boolean)  ("Andrus" <noeetasoftspam@online.ee>)
List pgsql-general
> I try to convert code from other database to Postgres.
>
> CREATE TABLE test(test BOOLEAN);
> SELECT MAX(test) FROM test;
>
> causes error
>
> ERROR:  function max(boolean) does not exist
> HINT:  No function matches the given name and argument types. You may need
> to add explicit type casts.
>
> I tried
> SELECT MAX(test:integer)::boolean FROM test;
>
> but this casuses error
>
> ERROR:  cannot cast type boolean to integer
>
> I have lot of MAX() functions applied to boolean expressions.
>
> How to force Postgres to calculate MAX(boolean) ?
>
> MAX(boolean) should return true if its argument evaluates true for at least
> one row.
>

Have you looked into creating a suitable aggregate function yourself?

\h CREATE AGGREGATE

http://www.postgresql.org/docs/current/static/xaggr.html
--
output = reverse("gro.gultn" "@" "enworbbc")
http://linuxdatabases.info/info/rdbms.html
"The  test of a  principle  is whether it  applies  even to people you
don't like." -- Henry Spencer

pgsql-general by date:

Previous
From: David Pratt
Date:
Subject: Re: Transparent i18n?
Next
From: Clark Allan
Date:
Subject: table name as variable within Function