I have a table with a unique id field, a userid field, and a date field.
What I want to do is have a column which flags if there is a record in the next 28 days with the same userid.
It is only the future i’m looking at, not past records..
id | uid | date | future
1 | 342 | 23/10/2007 | 1
2 | 342 | 3/11/2007 | 0
3 | 342 | 20/2/2009 | 0
4 | 147 | 22/2/2009 | 0
This is a basic example of the result i’m after.
I’m using mssql 2008
The following query would return the rows matching your requirement. If you want to, you could create a view from this query so that you could run other queries on just the future rows.