Re: Between with a list of ranges possible ? - Mailing list pgsql-general

From Stephen Cook
Subject Re: Between with a list of ranges possible ?
Date
Msg-id 5568A67B.8070206@gmail.com
Whole thread Raw
In response to Between with a list of ranges possible ?  (Arup Rakshit <aruprakshit@rocketmail.com>)
Responses Re: Between with a list of ranges possible ?
List pgsql-general
Use UNION ALL:

select * from table where number * 3  between start_value1 and end_value2
UNION ALL
select * from table where number * 3  between start_value2 and end_value2
UNION ALL
select * from table where number * 3  between start_value3 and end_value3;


-- Stephen

On 5/29/2015 12:32 PM, Arup Rakshit wrote:
> Hi,
>
> 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;
>
>



pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Between with a list of ranges possible ?
Next
From: John McKown
Date:
Subject: Re: Between with a list of ranges possible ?