CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2010
    Posts
    6

    SQL group by order by

    Code:
    SELECT * FROM $dbTable GROUP BY xNAME ORDER BY xDATETIME DESC
    What I am trying to do is extract only most recent entries for each unique xNAME. I can't figure out how to do this.

    SO here is my example table:

    john 8:00
    greg 9:00
    rick 10:00
    john 10:15
    rick 10:30
    greg 11:00

    and my desired result is:

    john 10:15
    greg 11:00
    rick 10:30

    Is this possible?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: SQL group by order by

    How about using Max(xDATETIME ?
    Victor Nijegorodov

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

Featured