Complex SQL syntax

  • I have a table "customers" with 2 fields: "ID" and "Name"

    there are multiple rows in this table with the same ID, and different Names.

    Example:

    ID Name

    ---------------

    201 M. Mamet

    201 Matthew Mamet

    How do i write -ONE- SQL statement that gets me a list of names for distinct IDs?

    I don't care which name it pulls, I just want a list of 1 name for 1 ID.

    Thanks!

    Matthew



    Matthew Mamet

  • select id, name = max(name)

    from tbl

    group by id


    Cursors never.
    DTS - only when needed and never to control.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply