Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Procedure to return multiple rows from table between 2 dates

Naveen BAug 14 2015 — edited Aug 14 2015

Need a procedure that will accept DATE1 and DATE2 as input parameters and then return records from a table that correspond to these dates grouped by CATEGORY and REGION.

For example in below table:  If ID=1, then DATE1 ='01JAN2014, and DATE2='01JAN2015'.

Table Structure: Each ID repeats twice within the table.

ID,CATEGORY, REGION, BOOK_DT

1,'ABC','EAST','01JAN2014'

1,'ABC','EAST','01JAN2015'

2,'ABC','EAST','01JAN2014'

3,'ABC','WEST','01JAN2015'

3,'ABC','WEST','30DEC2014'

4,'ABC','EAST','16JAN2015'

5,'XYZ','EAST','01JAN2015'

6,'XYZ','WEST','01JAN2015'

Expected Output: If DATE1='01JAN2014' and DATE2 = '01JAN2015'

ID, CATEGORY, REGION, DATE1, DATE2

1, 'ABC', 'EAST', '01JAN2014','01JAN2015

2, 'ABC', 'EAST', '01JAN2014', NULL

3, 'ABC', 'WEST', NULL, '01JAN2015'

5, 'XYZ', 'EAST', NULL, '01JAN2015'

6, 'XYZ', 'WEST', NULL, '01JAN2015'

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 11 2015
Added on Aug 14 2015
0 comments
58 views