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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DFirst wont work! how to display First and Last Records in a Query

Status
Not open for further replies.

ldXbl

Technical User
Apr 22, 2004
9
US
I have a query that pulles information about activities that occured at different times on one day. So i made it sort Assending by the time/date field and it is sorted correctly. Now i need to retrieve the First record and the last record from the query from the date/time filed. I tried using DLast and DFirst but in a sorted query they do not work correctly. They work fin in a table but that wont meet my needs

ActivityID
Description
ClientID
TimeID
particapated

the query sorts based on the timeId field. All i need is a way to get the first record and last record in the TimeID field. Thanks in advance for your help...
 
I am not clear on exactly what data you want returned in the query. If you just want earliest and latest timeid values then this will work:

SELECT MIN(TimeID) as FirstTime, MAX(TimeID) as LastTime FROM tblActivities
 
yes that is what i wanted to know, but is there a way to also put the sort into the same query so that it would sort by the clientID?? thanks for your help...
 
Do you want EACH client's Min and Max TimeID?

or do you want to find clients who's TimeID is between the Min and Max TimeID?



Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top