Question : QUERY

please find the attached table,
I need the first 7 dates records for each targetid
note:  the start date may be different for each targetid
example: result
targetid  date ...........fields
3002    02/24/1991
3002    02/24/1991
3002    02/25/1991
3002    02/26/1991
3002    02/27/1991
3002    02/28/1991
3002    02/1/1991
3002    02/2/1991
3002    02/2/1991
3003......
it repeats for all the target ids in the table



the seven dates will be min date for the target id and min+1 ,Min+2,...Min+3 i.e days will be consecutive for this table




 
Attachments:

Answer : QUERY

SELECT tblTSBC_SWRraw.TargetID as XTargetID, tblTSBC_SWRraw.Date as xDate, tblTSBC_SWRraw.*
FROM tblTSBC_SWRraw
Where tblTSBC_SWRraw.Date < (
 select min(B.Date) +7 from tblTSBC_SWRraw B
 where B.TargetID = tblTSBC_SWRraw.TargetID)
order by tblTSBC_SWRraw.TargetID, tblTSBC_SWRraw.Date
Random Solutions  
 
programming4us programming4us