Re: how to use aggregate functions in this case

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: how to use aggregate functions in this case
Date: 2013-08-27 18:27:06
Message-ID: 1377628026127-5768721.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Johnston wrote
>
> Janek Sendrowski wrote
>> Hi,
>>
>> &nbsp;
>>
>> thanks for all your answers.
>>
>> I&#39;ll have a try with the contains operator and the intrange, but
>> before I&#39;d like to know if this would work:
>>
>> &nbsp;
>>
>> CASE WHEN a &gt;= 0 AND a &lt;&nbsp;25
>>
>> CASE WHEN a &gt;=&nbsp;25 AND a &lt; 50
>>
>> &nbsp;
>>
>> There wouldn&#39;t be a double endpoint. I just have to decide which
>> range the endpoint includes.
>>
>> &nbsp;
>>
>> Janek Sendrowski
> Yes, using explicit comparison operators with "AND" will work just fine;
> its just a little more verbose so the other options, if available, are
> preferred from a readability standpoint. I do not know whether the
> different options may have different performance characteristics.
>
> David J.

And just for completeness:

WITH range_def (low, high, label) AS (
VALUES (0, 25, '0 to 25'::varchar), (25, 50, '25 to 50')
)
SELECT ...
FROM source_data
JOIN range_def ON (val >= low AND val < high)
[the rest of the query]

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/how-to-use-aggregate-functions-in-this-case-tp5768522p5768721.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message AI Rumman 2013-08-27 18:44:44 regexp idea
Previous Message Jeff Janes 2013-08-27 17:40:16 Re: Pgbouncer help