Search Postgresql Archives

Re: how to use aggregate functions in this case

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

 



David Johnston wrote
> 
> Janek Sendrowski wrote
>> Hi, 
>> 
>>   
>> 
>> thanks for all your answers. 
>> 
>> I'll have a try with the contains operator and the intrange, but
>> before I'd like to know if this would work: 
>> 
>>   
>> 
>> CASE WHEN a >= 0 AND a < 25 
>> 
>> CASE WHEN a >= 25 AND a < 50 
>> 
>>   
>> 
>> There wouldn't be a double endpoint. I just have to decide which
>> range the endpoint includes. 
>> 
>>   
>> 
>> 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.


-- 
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