Re: Select Rows With Only One of Two Values [RESOLVED]

From: Chris Angelico <rosuav(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Select Rows With Only One of Two Values [RESOLVED]
Date: 2012-07-20 16:25:28
Message-ID: CAPTjJmoUGCGzVQ6Eb4sxgK=yy-+qmE=Tr0POk7U10R_uWT6waw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jul 21, 2012 at 2:21 AM, Rich Shepard <rshepard(at)appl-ecosys(dot)com> wrote:
> On Sat, 21 Jul 2012, Chris Angelico wrote:
>
>> Try this:
>>
>> SELECT DISTINCT param FROM table WHERE indicator=0
>> EXCEPT
>> SELECT DISTINCT param FROM table WHERE indicator=1
>
>
> Chris,
>
> Thank you. I knew it was simple, and I've not before used the EXCEPT
> condition.
>
> Very much appreciate,
>
> Rich

No probs! SQL, like many other languages, allows you to combine its
primitives in some fairly complex ways. I don't know how hard it'd be
to make it work on Postgres, but here's an epic piece of SQL
awesomeness:

http://thedailywtf.com/Articles/Stupid-Coding-Tricks-The-TSQL-Madlebrot.aspx

ChrisA

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2012-07-20 16:33:02 Re: Select Rows With Only One of Two Values [RESOLVED]
Previous Message Rich Shepard 2012-07-20 16:21:04 Re: Select Rows With Only One of Two Values [RESOLVED]