Results 1 to 6 of 6

Thread: SQL return if for the column row there is only one number or many -- matching

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    okay I have a column where for example say I have the number

    100423 well I can have another 100423 it is not unique. How can I write code in SQL working in SQL that can do that.

    What I am basically trying to do is if there is only one instance of a particular number. I want to get a count of all those, any ideas?

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Location
    Germany
    Posts
    84
    you should create your recordset with an SQLString, which only selects the columns that match the number your looking for

    sqlString="SELECT * FROM table WHERE column=" & searchnumber

    afterwards you can see with Recordset.Recordcount how many records you have

    Hope this helps

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    i dont' now the exact number i want to select any numbers that only have one entry. . .

    Does this help or do i need help????

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    select key, count(key) from table group by key

    change the word "key" in the above SQL to the item you want to count...

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    You could add a HAVING clause to JHausmann's SQL statement. such as:
    select key, count(key) from table group by key
    HAVING count(key) = 1


    "It's cold gin time again ..."

    Check out my website here.

  6. #6
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    I agree, I missed the part where he said he only wanted one entry...

Posting Permissions

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



Click Here to Expand Forum to Full Width