Results 1 to 3 of 3

Thread: [RESOLVED] Select Max Date

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    169

    Resolved [RESOLVED] Select Max Date

    I have some records in a table, where I want to grab the most recent date and the other data associated with it. It's so simple when I think about it, but I just can't seem to write SQL that does what I want. (this is SQL Server 2005, by the way).

    Example.

    I have Person1, Person2, and Person3. Each person has a distinct date associated with it. I want to grab the Person field along with the max date, but I don't want to group by, because it will list all 3 persons. Does that make sense?

    Select Max(Date), Person From Person, it forces me to add a Group By Person, but then it lists all 3 Persons. It's annoying to say the least.

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Select Max Date

    Select Person,Date From Person Where Date = (Select Max(Date) From Person)
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    169

    Re: Select Max Date

    Yes, now I feel stupid. Thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width