Skip site navigation (1) Skip section navigation (2)

One query for two information...

From: "Ed" <dziablo(at)lords(dot)com>
To: "pgsql sql" <pgsql-sql(at)postgresql(dot)org>
Subject: One query for two information...
Date: 2000-04-18 14:26:25
Message-ID: 001d01bfa942$13d93180$ (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

I have a table containing only a bool filed.  I would like to know how many
records there is an on many ar true.

Is there something I could do to get both answer in only one query...   like

select count(*), sum(bool_col) from tablename

but there is no sum(bool) function that would add 1 if it's true and 0 if
it's false... ;(

Any idea?

Frédéric Boucher


pgsql-sql by date

Next:From: Allan KellyDate: 2000-04-18 15:16:29
Subject: Mystery: functions are slow with group by, but...
Previous:From: kaiqDate: 2000-04-18 14:15:58
Subject: Re: DELETE FROM tableA WHERE NOT IN tableB ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group