Select only Distinct Records

sql server India
  • 12 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

  • 12 years ago

    SELECT [name], MIN()
    FROM TableName
    GROUP BY [name]
    &nbsp;</p>

Post a reply

Enter your message below

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

Contribute

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.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth