Select Distinct Statement

  • I'm having a brain freeze today.

    I'm trying to find duplicate company records and insert the company record with the lowest ID number into another another.

    select distinct (company), min(ID)as ID

    into DistinctCompanies

    from companies

    group by company

    What am I missing?

    Thanks!

    Rog

  • Remove DISTINCT. Hope this helps

    SELECT company, min(ID)as ID

    INTO DistinctCompanies

    FROM companies

    GROUP BY company

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

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