Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Posts
    1

    Unanswered: Select Duplicate Values

    I am trying to select duplicate values for a field in a table. The table looks like the following:

    Code:
    OID   Product    Serial    Status
    1     100          abcd        3
    2     100          abcf        4
    3     100          abcd        3
    4     101          ebcd        3
    5     101          ebcf        4
    6     101          ebcd        3
    I would like my result set to be like the following:

    Code:
    Product    Serial    Status    Count
    100          abcd       3       2
    101          abcd       3       2
    Any ideas on how to get these results?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I'm sure the query would include the GROUP BY and HAVING clauses. You can find samples in the manual or in the wonderful SQL Cookbook by Graeme Birchall, which is available for free download.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963
    Quote Originally Posted by 37Seconds
    I am trying to select duplicate values for a field in a table. The table looks like the following:

    Code:
    OID   Product    Serial    Status
    1     100          abcd        3
    2     100          abcf        4
    3     100          abcd        3
    4     101          ebcd        3
    5     101          ebcf        4
    6     101          ebcd        3
    I would like my result set to be like the following:

    Code:
    Product    Serial    Status    Count
    100          abcd       3       2
    101          abcd       3       2
    Any ideas on how to get these results?
    Code:
    Select Product, Serial, Status, count(*) count
    from table1
    group by Product, Serial, Status
    having count(*) > 1
    Lenny

Posting Permissions

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