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'