Query
SELECT userid, lastseen
FROM user_login_management
GROUP BY userid
ORDER BY lastseen DESC
when I use group by
with order by DESC
then order by Desc
not work.
userid
is duplicated record and I'm trying to fetch the value of the latest row column named lastseen
matching userid
only.
If I use GROUP BY userid
it well works and removes duplications but in this case, the lastseen
column record is the first one of the matching id then I set ORDER BY lastseen DESC
but it does not work.
If I use it without GROUP BY
then it works. Is there any way to set GROUP BY
on userid
and ORDER BY DESC
on*lastseen
column?