Jump to content
Sign in to follow this  
Fjimenez

SQL question:I need to get the latest record base on date

Recommended Posts

Hello All, I am trying to get the latest record available for a field, I want to learn how to write/pull what I know as of  record status "1" from my results

since let's say; an activity was updated several times but I just need the latest update base on the date, I tried using distinct and it worked: each row is different but I am still receiving all the updates of each activity. I tried to use (Group by) base in the activity Id and I am receiving this error message "Column 'activity_name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

 

 I am using the Microsoft SQL server management studio.

Share this post


Link to post
Share on other sites

Use MAX if you want the largest value or MIN for the smallest.  You need to group by every column that is not part of the aggregate function.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...