create table t ( id integer, dt date)
insert into t values (1,sysdate);
insert into t values (2,sysdate-1);
insert into t values (3,sysdate-2);
insert into t values (4,sysdate-3);
insert into t values (5,sysdate-4);
insert into t values (6,sysdate-5);
insert into t values (8,sysdate-7);
I have data as follows.
ID DT
++++++++++++++++++++++++
1 07-JUN-10
2 06-JUN-10
3 05-JUN-10
4 04-JUN-10
5 03-JUN-10
6 02-JUN-10
8 31-MAY-10
Now i need to write a query to return data which comes under 3 days (thois could be 4- its a user input) window.
e.g.
Query will start from 07 June and will go back 3 days i.e. till 4th June, now since there is data for 4th june it will go back till 1st June. Now we do not have data for 1-Jun so it will stop here and query will return all record except for 31st May.
I do not have choice of writing procedure here. can someone help.