I have a table
Tew which has multiple rows like( for a branchid, user has maintained multiple ranges of accounts )
Branch id Low High Account_Range
100 80 95 80-95
100 100 110 100-110
100 150 155 150-155
Create table tew(Branchid varchar2(10), Low number , High number, Account_Range varchar2(30));
insert into tew values(100,80,95,'80-95');
insert into tew values(100,100,110,'100-110');
insert into tew values(100,150,155,'150-155');
It means that for Branch id 100, I have all these ranges applicable for accounts( Any account that is in between these ranges should be processed and anything not in range ignored).
One way is to have three different queries and joining them by union
But I would like to combine all the different account ranges into one query.
Something similar to
Select '1' from tew where branchid =100 and ((account_range between 80 and 90 )or( account range between 100 and 110) or( account_range between 150 and 155))
I am going to retrieve account from another table and this table would be used to validate if for that brancid , the account falls in the range or not. If it falls in range it would be processed else it would be ignored.
Is there a better way of doing this ?