Select only Distinct Records

sql server India
  • 10 years ago

    Hi ,

    name                     code

    2-Part Finish         114012
    2-Part Finish         114013
    2-Part Finish         114014
    2-Part Finish         114015
    2-Part Finish         114016
    Abrasive Wheel         114018
    Abrasive Wheel         114019
    Abrasive Wheel Kit 114020
    Abrasive Wheel Kit 114021
    Abrasive Wheel Kit 114022

    The above is my table format in sql server 2000 db

    I want the output to be of the format as below:

    name                     code

    2-Part Finish        114012
    Abrasive Wheel         114018
    Abrasive Wheel Kit 114020

    I want to do it in sql server query analyser only

    Plz help

    Thanks in Advance

  • 10 years ago

    SELECT [name], MIN()
    FROM TableName
    GROUP BY [name]

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor