Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: How to delete duplicate raws


Message #1 by Urvish Panchal <urvishpanchal@y...> on Sat, 13 May 2000 23:06:10 -0700 (PDT)
  Hi !!


  My Name is Marcelo , I from Brazil

  (Exchange for my poor English)
Try It
delete
    from mytable
where
    col_a in
    (
        select
              a.col_a
        from
            mytable a,
            mytable b
        where
            a.col_a = b.col_a
        group by
            a.col_a
        having
             count(a.col_a) >1
    )




>From: Urvish Panchal <urvishpanchal@y...>
>Reply-To: "sql language" <sql_language@p...>
>To: "sql language" <sql_language@p...>
>Subject: [sql_language] How to delete duplicate raws
>Date: Sat, 13 May 2000 23:06:10 -0700 (PDT)
>
>I have one table having text data type with more than
>one records. I mean may be one or more than one record
>with same datalength. Now I want to delete only one
>such raws which is duplicate in the table but at the
>same time one raws of the same record should be remain
>in the table.
>
>table mytable ( col_a int,col_b text)
>    col_a  col_b
>
>     1       abcd
>     1       abcd
>     2       defg
>     2       def
>     3       x
>     4       o
>     5       mn
>     5       mn
>
>Total Raws : 8
>Out put
>    col_a  col_b
>     1     abcd
>     2     defg
>     3     x
>     4     o
>     5     mn
>
>   Total Raws : 5
>
>I am also checking the datalength function through
>derived table base query for this. I don't want to use
>any temp table I want to do the same in only one
>select T-SQL query. Can it be possible ???
>Please send me the reply ASAP.
>
>Urvish
>



  Return to Index