Professional Web Applications Themes

Select no duplicate value in a column - Microsoft SQL / MS SQL Server

Hi All I need to select from a table where data is duplicated in a column. I dont want duplicate values so i put a distinct clause but still getting duplicate columns because other some of the other fields dont have exact values. I want only the unique values for a column ! how can do this. NM...

  1. #1

    Default Select no duplicate value in a column

    Hi All

    I need to select from a table where data is duplicated in a column.
    I dont want duplicate values so i put a distinct clause but still getting
    duplicate columns
    because other some of the other fields dont have exact values.

    I want only the unique values for a column ! how can do this.

    NM


    Noor Guest

  2. #2

    Default Re: Select no duplicate value in a column

    > I need to select from a table where data is duplicated in a column. 

    Then you're going to have to explain what you want. If you have columns
    like this:

    FirstName LastName

    And you have rows like this:

    John Smith
    John Appleseed
    John Franco
    Joe DiMaggio
    Joe Thornton

    And you want unique first names, which last name goes with that row?

    Show table structure, sample data, and desired results (see
    http://www.aspfaq.com/5006) and someone can give you a more meaningful
    answer.


    Aaron Guest

  3. #3

    Default Re: Select no duplicate value in a column

    You are right..

    I just want the first match.. and ignore the rest.

    is this possible?

    NM



    "Aaron Bertrand [MVP]" <com> wrote in message
    news:#kJPBM$phx.gbl... [/ref]
    getting 
    >
    > Then you're going to have to explain what you want. If you have columns
    > like this:
    >
    > FirstName LastName
    >
    > And you have rows like this:
    >
    > John Smith
    > John Appleseed
    > John Franco
    > Joe DiMaggio
    > Joe Thornton
    >
    > And you want unique first names, which last name goes with that row?
    >
    > Show table structure, sample data, and desired results (see
    > http://www.aspfaq.com/5006) and someone can give you a more meaningful
    > answer.
    >
    >[/ref]


    Noor Guest

  4. #4

    Default Re: Select no duplicate value in a column

    > I just want the first match.. and ignore the rest. 

    No, you need to define "first"... remember that tables are just unordered
    heaps, if you're expecting some order to come out of a table, you need to
    use ORDER BY or use an aggregate function (e.g. MIN() or MAX()) to tell the
    database which one you want.

    If you show your table structure, sample data, and desired results, we can
    help.


    Aaron Guest

Similar Threads

  1. Replies: 2
    Last Post: August 7th, 02:11 PM
  2. Select DIV and duplicate it
    By naked_ollie in forum Macromedia Contribute General Discussion
    Replies: 2
    Last Post: August 10th, 12:02 PM
  3. MS Access SQL: duplicate record... ?SELECT INTO....?
    By Scotter in forum ASP Database
    Replies: 8
    Last Post: June 30th, 12:25 PM
  4. select all the duplicate records
    By atse in forum ASP
    Replies: 9
    Last Post: October 19th, 06:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139