Re: Between with a list of ranges possible ?

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Between with a list of ranges possible ?
Date: 2015-05-29 17:41:20
Message-ID: 5568A4C0.4040900@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/29/2015 9:32 AM, Arup Rakshit wrote:
> Can I do the below 3 queries in a single query ?
>
> select * from table where number * 3 between start_value1 and end_value2;
> select * from table where number * 3 between start_value2 and end_value2;
> select * from table where number * 3 between start_value3 and end_value3;

select * from table where (number * 3 between start_value1 and end_value2) OR
(number * 3 between start_value2 and end_value2) OR
(number * 3 between start_value3 and end_value3);

--
john r pierce, recycling bits in santa cruz

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2015-05-29 17:43:34 Re: Between with a list of ranges possible ?
Previous Message Robert Haas 2015-05-29 16:43:34 Re: [HACKERS] Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1