Select Rows With Only One of Two Values - Mailing list pgsql-general

From Rich Shepard
Subject Select Rows With Only One of Two Values
Date
Msg-id alpine.LNX.2.00.1207200844110.21688@salmo.appl-ecosys.com
Whole thread Raw
Responses Re: Select Rows With Only One of Two Values  (Chris Angelico <rosuav@gmail.com>)
List pgsql-general
   What I thought would be a simple, single table select keeps eluding me.
I've looked in Rick van der Laans' book and the Joe Celko books here and
have not learned how to write the query.

   The table has a Boolean indicator column with values of 0 or 1 for each
row in the table and another attribute column for parameter names. I need to
find all parameter names where the indicator value is only 0 for all rows of
that parameter. At least some of the parameters have both rows with 0 and
rows with 1 in the indicator attribute. I want to find all (any?) that have
only zeros.

   I have tried various flavors of this non-working syntax:

SELECT DISTINCT(param) from table WHERE indicator = 0 and indicator <> 1
order by param;

and have not found the correct way of writing this either directly or as a
correlated query. The proper syntax must not be complicated and I would
appreciate learning how to write it.

Rich


pgsql-general by date:

Previous
From: Christian Ullrich
Date:
Subject: Re: I cannot insert bengali character in UTF8
Next
From: Chris Angelico
Date:
Subject: Re: Select Rows With Only One of Two Values