I don't understand the question.
Which of the following do you want:
== the number of users that have been activated during the month
== the number of users that have been activated prior to the end of the month
The users have been activated at some time in the past
== the number of users that are active as of the end of the month. The users
have been activated prior to the end of the month and their status has not
changed to something else like "inactive" before the end of the month
== some other definition of what you are looking for.
This query gives the count per month where a record with the status of
Activated exists and the Flag is equal to an asterisk (*).
SELECT Format([DateField],"yyyy-mm") as YearMonth
, Count([DateField]) as Activated
FROM USERS_LOG
WHERE STATE="ACTIVATED" AND FLAG="*"
GROUP BY Format([DateField],"yyyy-mm")
Also can you post the actual names of your fields and the field types.
User ID >>>> ??????
User State >>> STATE
Date/Time of entry >>> ?????
Last State Flag >>>>FLAG
What values does Last State Flag (FLAG) have and what do they signify?
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
How to show the balance of activated users for each month?
I want to know how many users were activated at end of month.
Is it possible?
SELECT Format([DateField],"yyyy-mm") as YearMonth
, Count([DateField]) as Activated
FROM USERS_LOG
WHERE STATE="ACTIVATED" AND FLAG="*"
GROUP BY Format([DateField],"yyyy-mm")
If you are trying to do this as a sub-query then all you may need to do is add
a bit more to the where clause.
(SELECT COUNT(*) AS ACTIVATED
FROM USERS_LOG As Temp
WHERE STATE="ACTIVATED"
AND FLAG="*"
AND Format(Temp.[DateField],"yyyymm")=Format(Users_Log.[DateField],"yyyymm"))
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Kamil wrote:
Hi.
I have a table with users log. It contains user id, user state, date/
time of entry and last state flag. Each time user state is changed
there is new entry in that log.
One of the states is "ACTIVATED".
I need to create a query, which will show the number of activated
users monthly.
It's easy to show current number (SELECT COUNT(*) AS ACTIVATED FROM
USERS_LOG WHERE STATE="ACTIVATED" AND FLAG="*")
but how to show it monthly?
Best regards,
Kamil