Fjimenez Posted August 12, 2019 Share Posted August 12, 2019 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. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 12, 2019 Share Posted August 12, 2019 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now