need 1st and last date of customer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a query that will display the first and last date a customer attends
during a month, how do i do this? Thanks
 
Iain said:
I need a query that will display the first and last date a customer attends
during a month, how do i do this? Thanks

(air code)

For all months...

SELECT Format(AttendDate, "yyyy-mm") As Month,
CustomerID,
Min(AttendDate) As FirstDate,
Max(AttendDate) As LastDate
FROM TableName
GROUP BY Format(AttendDate, "yyyy-mm"), CustomerID

For a given month...

SELECT CustomerID,
Min(AttendDate) As FirstDate,
Max(AttendDate) As LastDate
FROM TableName
WHERE AttendDate BETWEEN #1/1/2005# AND #2/1/2005#
GROUP BY CustomerID
 
Back
Top