Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    32

    Unanswered: Heirarchical Count of Duplicates

    The "Duplicate" field in my MySQL database contains record IDs from other records submitted on different dates by different people with different contact information, etc., that require basically the same action.

    I used a MySQL query to sort the database using the Duplicate field, and then used PHP to search the query results and list duplicates as follows:

    $NumberOfDuplicates people submitted request $RecordID.

    At present, my results are not ranked. For example, I may get:

    3 people submitted request 1.
    10 people submitted request 2.
    7 people submitted request 3.

    Is there an efficient way to rank the collected results so that I can display:

    10 people submitted request 2.
    7 people submitted request 3.
    3 people submitted request 1.

    Thanks!

    Tim

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    select count(*) as duplicates, recordid
    from yourtable
    group by recordid
    order by recordid, duplicates desc


    rudy

  3. #3
    Join Date
    Oct 2002
    Posts
    32

    Thank you!

    It took me a while to figure out that you really meant duplicates and not the field name Duplicate. Nevertheless, your solution works. Thank you!

    Timm

Posting Permissions

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