This discussion is archived
4 Replies Latest reply: Aug 8, 2013 11:28 AM by Frank Kulash RSS

Help in sql

943841 Newbie
Currently Being Moderated
create table ramx ( id number, start_date date, end_date date, type_id number);
Insert into ramx values (1,to_date ('8/27/2007' , 'mm/dd/yyyy') ,to_date ('12/30/2007' , 'mm/dd/yyyy'),1);
Insert into ramx values (1,to_date ('12/31/2007','mm/dd/yyyy')  ,to_date ('5/9/2009' , 'mm/dd/yyyy'),1);
Insert into ramx values (1,to_date ('5/10/2009 , 'mm/dd/yyyy') ,to_date ('5/17/2009' , 'mm/dd/yyyy'),2);
Insert into ramx values (1,to_date ('5/18/2009' , 'mm/dd/yyyy') ,to_date ('7/5/2009' , 'mm/dd/yyyy'),2);
Insert into ramx values (1,to_date ('7/6/2009' , 'mm/dd/yyyy') ,to_date ('8/2/2009' , 'mm/dd/yyyy'),3);
Insert into ramx values (1,to_date ('8/3/2009' , 'mm/dd/yyyy') ,to_date ('9/15/2009' , 'mm/dd/yyyy'),1);
Insert into ramx values (1,to_date ('9/16/2009' , 'mm/dd/yyyy') ,to_date ('10/14/2009' , 'mm/dd/yyyy'),2);
Insert into ramx values (1,to_date ('10/15/2009','mm/dd/yyyy')  ,to_date ('10/31/2010' , 'mm/dd/yyyy'),2);

 

The requirement is to get the single row based on start_date and end_date. for example result should be

 

1 8/27/2007 5/9/2009 1
1 5/10/2009 7/5/2009 2
1 7/6/2009  8/2/2009 3
1 8/3/2009  10/14/2009 1
1 9/16/2009 10/31/2010 2

 

Can you help on this.

 

Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points