Search Postgresql Archives

Select Rows With Only One of Two Values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux