Link to home
Start Free TrialLog in
Avatar of bearpaws

asked on

Selecting max value for each unique entry

Hi folks,
  I have a log table in which each time a client signs in, it records the date /time by the client id.
So, basically a client can have many records. I am trying to construct a query that will allow me
list the client just once and the most recent login date/time from this table.
 I also need to pull from the ClientMaster table, thier name and address. How can I do construct this query?
I have tried combinations of select distinct but then trip on getting the max(login date/time) and trying to
pull their name and so forth from the ClientMaster.
Any help would be appreciated.
Avatar of chapmandew
Flag of United States of America image

select cm.Name, cm.Address, cm.ClientID, MAX(cl.LoginDate) as lastlogin
clientmaster cm join clientlogins cl on cm.clientid = cl.clientid
group by, cm.address, cm.clientid
Avatar of LordOfPorts
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
He had the same code that I posted before...
Avatar of bearpaws


Not exactly, are you upset that I did not award points to you also?
If so, I will check with the monitor about also awarding you points.
It is the same query, only his had an order by.....