Thread: Distinct
View Single Post

  #2 (permalink)  
Old 12-22-2007
J.O. Aho
 
Posts: n/a
Default Re: Distinct

Axelar wrote:
> Hi :)
>
> i don't know how to get the last record of each distinct entries in
> one of my table connexion. The table contains trace of connexions on a
> website. The fields are id, date, hour, user, browser, pageviewed.
>
> If i use "SELECT DISTINCT(user) FROM connexions ORDER BY date DESC,
> heure DESC" i get just the name of the each user
>
> If i use "SELECT DISTINCT(user),date,hour FROM connexions ORDER BY
> date DESC, heure DESC" i get more than one line per user !?
>
> What's the right way to obtain a list of each user last connexion ?
>
> Thanks in advance !


Try
SELECT user, date, hour FROM connexions ORDER BY date DESC , hour DESC GROUP
BY user

--

//Aho
Reply With Quote