Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed to query data 1

Status
Not open for further replies.

JohnnyLong

Programmer
Sep 27, 2002
97
GB
I have a Timesheet table which stores the employee names and week commencing dates for each timesheet (they are paid weekly). I need to see who has not received a timesheet in the last 4 weeks. Here is an example of my data:

Name TS Week
John Smith 06/11/2006
John Smith 30/10/2006
John Smith 23/10/2006
John Smith 16/10/2006
etc
Joe Bloggs 09/10/2006
Joe Bloggs 02/10/2006
Joe Bloggs 25/09/2006
Joe Bloggs 18/09/2006
etc

So in the above example John Smith has worked in the last 4 weeks but Joe Bloggs hasn't. I need my query results to show Joe Bloggs 09/10/2006 (his last timesheet). I'm guessing that I need to group my results, but I don't know how. Any ideas greatly appreciated.
 
Perhaps something like:

[tt]SELECT tblTable.Name, Max(tblTable.[TS Week]) AS [MaxOfTS Week]
FROM tblTable
GROUP BY tblTable.Name
HAVING (((Max(tblTable.[TS Week]))<Date()-28));[/tt]
 
Thanks alot Remou, that's just what I needed. You are a life saver.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top