Re: NOT HAVING clause?

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: andrew(at)supernews(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: NOT HAVING clause?
Date: 2006-01-25 11:14:56
Message-ID: 43D75DB0.4030108@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew - Supernews wrote:
> On 2006-01-24, Will Glynn <wglynn(at)freedomhealthcare(dot)org> wrote:
>
>>You might try:
>>
>>SELECT some_column
>> FROM some_table
>> GROUP BY some_column
>> HAVING SUM(CASE WHEN sort_order=1 THEN 1 ELSE 0 END) = 0;
>
>
> SELECT some_column
> FROM some_table
> GROUP BY some_column
> HAVING every(sort_order <> 1);
>
> every() is in 8.1 at least (can't recall when it was introduced); it's the
> same as bool_and(), i.e. an aggregate that returns true only if all inputs
> are true. Why isn't there a corresponding any(), I wonder? (bool_or does
> exist)

Unfortunately we still use 7.4, but I realized this morning that this
should work too (not tried yet):

SELECT some_column
FROM some_table
GROUP BY some_column
HAVING MIN(sort_order) > 1;

As our sort_orders start from 1.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

//Showing your Vision to the World//

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marcos 2006-01-25 11:31:55 Tsearch 2
Previous Message Andrew Maclean 2006-01-25 11:01:17 Re: Does this look ethical to you?