i have table create table table1 ( from_id varchar2(10), to_id varchar2(10), b_id varchar2(20) not null, exp_in_date varchar2(20) not null ); sample data: insert table1 (from_id,to_id,b_id,exp_in_date) values ('5','2','20140203056',to_date('20140203', 'yyyymmdd')); insert table1 (from_id,to_id,b_id,exp_in_date) values ('5','2','20140203056',to_date('20140203', 'yyyymmdd')); insert table1 (from_id,to_id,b_id,exp_in_date) values ('5','1','20140203056',to_date('20140203', 'yyyymmdd')); insert table1 (from_id,to_id,b_id,exp_in_date) values ('5','2','20140203057',to_date('20140203', 'yyyymmdd')); insert table1 (from_id,to_id,b_id,exp_in_date) values ('2','5','20140203057',to_date('20140203', 'yyyymmdd')); insert table1 (from_id,to_id,b_id,exp_in_date) values ('5',...