#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    7
    Rep Power
    0

    Max id if multiple records exist help please!!


    Hi,

    i am having a hard time figuring out how to go about this.

    so basically IF multiple records with the same start date exist, i have to select the one with the max(note_id)

    Example
    note_id/start_date
    88888/08-01-2001
    98788/08-01-2001 <===
    55555/08-01-2001
    54856/08-01-2001

    in the example above, i would need to pick the one with the arrow
    note_id-98788 and start_date-08-01-2001
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,148
    Rep Power
    4274
    Code:
    SELECT start_date
         , MAX(note_id) 
      FROM daTable
    GROUP
        BY start_date
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo