how to find duplicated rows in a table

  • Comments posted to this topic are about the item how to find duplicated rows in a table

  • edit: this should be one of the most basic queries ever. so, i have been surprised why you have choosen to add an identity column and querying the table twice with joins, etc.

    shouldn't the script below suit your needs?

    select y,x

    from t1 (NOLOCK)

    group by y, x

    having count(1) > 1

  • Infact, I didin't understand why you wrote like that code.

    Where is the difference from below code.

    I think It's very easy.

    SELECT * FROM t1 WHERE y IN (

    SELECT y FROM t1

    GROUP BY y

    HAVING COUNT(y)>1

    )

    Thanks.

  • this has gotta be the most pathetic script i've ever seen...

    I'm surprised SSC even published this!!

  • WHY???

    you can use the following

    [font="Courier New"]SELECT

    x,

    y,

    COUNT(y) AS How_Many_Times

    FROM t1

    GROUP BY x, y

    HAVING (COUNT(y) > 1)[/font]

    I don't understand 1.why do you have to add a rowid!! 2.what is the purpose of adding a third column (z) with a default value of zero!!!

  • ABHILASH DHONGDI (6/18/2008)


    this has gotta be the most pathetic script i've ever seen...

    I'm surprised SSC even published this!!

    My thoughts, exactly. You can pick any line in the article and find problems with it. Awful.

  • I would have to agree with the other posts...

    this script stinks on ice.

    How does this warrant a hyperlink to the "solution script".

    Lets keep the quality of the site high....

    Fortunately, it usually is

    :sick:

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply