Re: Query to show last time someone logged in.

Tech-Archive recommends: Speed Up your PC by fixing your registry



On Tue, 24 May 2005 21:34:02 -0700, "Jonathan Brown"
<JonathanBrown@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>When my users log into my database a query automatically runs and creates a
>new record in a table called tblUsageStats. Each record contains the user's
>Username and the Current date & time (Now()).
>
>I want to create a query now that will pull from that table only the last
>time each user logged in. So it would probably looks something like:
>
>FROM "tblUsageStats"
>Select "Username" & "Date"
>Where "Date" = "The last time they logged in" or "The closest date to NOW()"
>
>This is not to say, "Who was the last person to login?" but "when was the
>last time each user logged in?"
>
>Thanks a ton.

A Subquery will do this:

SELECT [Username], [Date]
FROM [tblUsageStats]
WHERE [Date] = (SELECT Max([Date]) FROM tblUsageStats AS X
WHERE X.[Username] = [tblUsageStats].[Username]);

Note that fieldnames must be delimited with [brackets] not "quotes",
or you'll retrieve the literal string values "Username" and "Date".
Also, the field named Date should be renamed - that's a reserved word
and very well may cause problems.

John W. Vinson[MVP]
.



Relevant Pages

  • Query to show last time someone logged in.
    ... When my users log into my database a query automatically runs and creates a ... new record in a table called tblUsageStats. ... Username and the Current date & time ). ...
    (microsoft.public.access.queries)
  • Re: How to change username?
    ... I'm reading that erick is storing the username with the data that 'belongs' to that user. ... So you'll need to delete all the users (no you can't change the existing usernames), recreate them, and then run a bunch of update queries to update the existing data to the new username. ... then have the users log in using ... The database control expenses for around 30+ ...
    (microsoft.public.access.security)
  • REPOST: bug in Forms Authentication
    ... i have a minor problem where some users log in with capital letters ... for their username, which looks bad when displayed on screen and also ... // find the Membership User ... // use the correct username case (from the aspnetdb database) ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: How to change username?
    ... It has no connection to stored data. ... then have the users log in using the new names. ... The database control expenses for around 30+ ... Is there a way I can link the old username with ...
    (microsoft.public.access.security)
  • Re: Query to show last time someone logged in.
    ... "John Vinson" wrote: ... >>When my users log into my database a query automatically runs and creates a ... >>new record in a table called tblUsageStats. ...
    (microsoft.public.access.queries)