title: SQL Server - How to select the most recent record per user?
body: <p>I am trying to execute a SQL command which should draw on the last row that entered the database.</p>
  
  <p>Basically, when a user submits the last thread (like in this forum), it redirects the user to a page with his thread title, thread paragraph and data such as a user name and time the thread was submitted.</p>
  
  <p>I started working on the statement:</p>
  
  <pre><code>SELECT @UserID, u.UsersName, t.ThreadTitle, t.ThreadParagraph
  FROM Users as u
  INNER JOIN Threads as t ON u.UserID = t.UserID
  Where @UserID = t.UserId
  </code></pre>
  
  <p>The problem that I have is that i need to add some statement or aggregate function to return me the last row that was entered in the threads table. How do I do this? what do I need to add?</p>