I have a SQL db which is populated by a LoginScript.
Every row represents an unique Login and have several fields like ID,TIME,USERID,CLIENT, etc.
What I wonder is if I can, with a single SELECT get only 1 row (or few fields) per user, the LATEST, from lets say 1 month back?
It is a SQL Server 2008
I am not (yet) familiar with "combings" like this but I'm on my way ;)
Your answer seems to work exactly the way I want!! :)
I removed and added some to get what I really needed and now I am really happy!! :)
,ROW_NUMBER() OVER(PARTITION BY USERID ORDER BY TIME1 DESC) AS RN
FROM TABLE) D
WHERE RN = 1 AND TIME1>'2018-03-01 00:00:00'
ORDER BY TIME1 DESC
Thank you very much!!!!!