Loading ...
Sorry, an error occurred while loading the content.

How to delete repeated data from a table?

Expand Messages
  • Ved Prakash
    Hi, I have a problem. How to delete repeated data from a table? Can any body help me to out of the prob. Prob: I have a table Table1. There is no primary key.
    Message 1 of 10 , Mar 5 9:06 AM
    • 0 Attachment
      Hi,

      I have a problem. How to delete repeated data from a table?
      Can any body help me to out of the prob.

      Prob:
      I have a table Table1. There is no primary key. There is repeted data in the table1
      e.g
      Table1 Data
      -------------------------------------------------------------------------------
      Name Sal
      ------------------------------------------------------------------------------
      A 3000
      B 2000
      B 2000
      C 1000
      C 1000
      C 1000
      A 3000
      D 5000
      B 2000
      -----------------------------------------------------------------------------
      Now I have to write a query which will delete the repeated data.
      As for this example Output should be

      -------------------------------------------------------------------------------
      Name Sal
      ------------------------------------------------------------------------------
      A 3000
      B 2000
      C 1000
      D 5000
      -----------------------------------------------------------------------------
      Thanks in Adv.
      Prakash



      ---------------------------------
      Want to start your own business? Learn how on Yahoo! Small Business.

      [Non-text portions of this message have been removed]
    • Michael Weiss
      Try www.15secnds.com - there is an article there by David Penton which covers deleting dupe records. Regards, Michael _____ From:
      Message 2 of 10 , Mar 5 2:51 PM
      • 0 Attachment
        Try www.15secnds.com <http://www.15secnds.com/> - there is an article
        there by David Penton which covers deleting dupe records.

        Regards,

        Michael



        _____

        From: SQLQueriesNoCode@yahoogroups.com
        [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Ved Prakash
        Sent: Monday, March 05, 2007 9:07 AM
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: [SQLQueriesNoCode] How to delete repeated data from a table?



        Hi,

        I have a problem. How to delete repeated data from a table?
        Can any body help me to out of the prob.

        Prob:
        I have a table Table1. There is no primary key. There is repeted data in
        the table1
        e.g
        Table1 Data
        ----------------------------------------------------------
        Name Sal
        ----------------------------------------------------------
        A 3000
        B 2000
        B 2000
        C 1000
        C 1000
        C 1000
        A 3000
        D 5000
        B 2000
        ----------------------------------------------------------
        Now I have to write a query which will delete the repeated data.
        As for this example Output should be

        ----------------------------------------------------------
        Name Sal
        ----------------------------------------------------------
        A 3000
        B 2000
        C 1000
        D 5000
        ----------------------------------------------------------
        Thanks in Adv.
        Prakash

        ---------------------------------
        Want to start your own business? Learn how on Yahoo! Small Business.

        [Non-text portions of this message have been removed]





        [Non-text portions of this message have been removed]
      • Stephen Russell
        Why not do a count for rows first? Stephen Russell DBA / .Net Developer Memphis TN 38115 901.246-0159 A good way to judge people is by observing how they
        Message 3 of 10 , Mar 5 2:59 PM
        • 0 Attachment
          Why not do a count for rows first?


          Stephen Russell
          DBA / .Net Developer

          Memphis TN 38115
          901.246-0159

          "A good way to judge people is by observing how they treat those who can do
          them absolutely no good."
          ---Unknown

          HYPERLINK
          "http://spaces.msn.com/members/srussell/"http://spaces.msn.com/members/sruss
          ell/



          _____

          From: Ved Prakash [mailto:vedprakash4@...]
          Sent: Monday, March 05, 2007 11:07 AM
          To: SQLQueriesNoCode@yahoogroups.com
          Subject: [SQLQueriesNoCode] How to delete repeated data from a table?



          Hi,

          I have a problem. How to delete repeated data from a table?
          Can any body help me to out of the prob.

          Prob:
          I have a table Table1. There is no primary key. There is repeted data in the
          table1
          e.g
          Table1 Data
          ----------------------------------------------------------------
          Name Sal
          ----------------------------------------------------------------
          A 3000
          B 2000
          B 2000
          C 1000
          C 1000
          C 1000
          A 3000
          D 5000
          B 2000
          ----------------------------------------------------------------
          Now I have to write a query which will delete the repeated data.
          As for this example Output should be

          ----------------------------------------------------------------
          Name Sal
          ----------------------------------------------------------------
          A 3000
          B 2000
          C 1000
          D 5000
          ----------------------------------------------------------------
          Thanks in Adv.
          Prakash

          ------------------------------------
          Want to start your own business? Learn how on Yahoo! Small Business.

          [Non-text portions of this message have been removed]






          --
          No virus found in this incoming message.
          Checked by AVG Free Edition.
          Version: 7.5.446 / Virus Database: 268.18.7/711 - Release Date: 3/5/2007
          9:41 AM



          --
          No virus found in this outgoing message.
          Checked by AVG Free Edition.
          Version: 7.5.446 / Virus Database: 268.18.7/711 - Release Date: 3/5/2007
          9:41 AM



          [Non-text portions of this message have been removed]
        • John Warner
          Note it is: www.15seconds.com Note the o between c and n . Makes all the difference in the world to the help you will get. The para-site is a waste of
          Message 4 of 10 , Mar 5 3:06 PM
          • 0 Attachment
            Note it is:
            www.15seconds.com

            Note the "o" between "c" and "n". Makes all the difference in the world
            to the help you will get.

            The para-site is a waste of your time


            John Warner


            > -----Original Message-----
            > From: SQLQueriesNoCode@yahoogroups.com
            > [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Michael Weiss
            > Sent: Monday, March 05, 2007 5:55 PM
            > To: SQLQueriesNoCode@yahoogroups.com
            > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
            > from a table?
            >
            >
            > Try www.15secnds.com <http://www.15secnds.com/> - there is
            > an article there by David Penton which covers deleting dupe records.
            >
            > Regards,
            >
            > Michael
            >
            >
            >
            > _____
            >
            > From: SQLQueriesNoCode@yahoogroups.com
            > [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Ved Prakash
            > Sent: Monday, March 05, 2007 9:07 AM
            > To: SQLQueriesNoCode@yahoogroups.com
            > Subject: [SQLQueriesNoCode] How to delete repeated data from a table?
            >
            >
            >
            > Hi,
            >
            > I have a problem. How to delete repeated data from a table?
            > Can any body help me to out of the prob.
            >
            > Prob:
            > I have a table Table1. There is no primary key. There is
            > repeted data in the table1 e.g Table1 Data
            > ----------------------------------------------------------
            > Name Sal
            > ----------------------------------------------------------
            > A 3000
            > B 2000
            > B 2000
            > C 1000
            > C 1000
            > C 1000
            > A 3000
            > D 5000
            > B 2000
            > ----------------------------------------------------------
            > Now I have to write a query which will delete the repeated
            > data. As for this example Output should be
            >
            > ----------------------------------------------------------
            > Name Sal
            > ----------------------------------------------------------
            > A 3000
            > B 2000
            > C 1000
            > D 5000
            > ----------------------------------------------------------
            > Thanks in Adv.
            > Prakash
            >
          • Michael Weiss
            Ooh Good catch, John! Thanks! I didn t even notice the typo... Michael _____ From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com]
            Message 5 of 10 , Mar 5 3:55 PM
            • 0 Attachment
              Ooh Good catch, John! Thanks! I didn't even notice the typo...

              Michael



              _____

              From: SQLQueriesNoCode@yahoogroups.com
              [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of John Warner
              Sent: Monday, March 05, 2007 3:06 PM
              To: SQLQueriesNoCode@yahoogroups.com
              Subject: RE: [SQLQueriesNoCode] How to delete repeated data from a
              table?



              Note it is:
              www.15seconds.com

              Note the "o" between "c" and "n". Makes all the difference in the world
              to the help you will get.

              The para-site is a waste of your time

              John Warner

              > -----Original Message-----
              > From: SQLQueriesNoCode@yahoogroups.com
              <mailto:SQLQueriesNoCode%40yahoogroups.com>
              > [mailto:SQLQueriesNoCode@yahoogroups.com
              <mailto:SQLQueriesNoCode%40yahoogroups.com> ] On Behalf Of Michael Weiss
              > Sent: Monday, March 05, 2007 5:55 PM
              > To: SQLQueriesNoCode@yahoogroups.com
              <mailto:SQLQueriesNoCode%40yahoogroups.com>
              > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
              > from a table?
              >
              >
              > Try www.15secnds.com <http://www.15secnds.com/
              <http://www.15secnds.com/> > - there is
              > an article there by David Penton which covers deleting dupe records.
              >
              > Regards,
              >
              > Michael
              >
              >
              >
              > _____
              >
              > From: SQLQueriesNoCode@yahoogroups.com
              <mailto:SQLQueriesNoCode%40yahoogroups.com>
              > [mailto:SQLQueriesNoCode@yahoogroups.com
              <mailto:SQLQueriesNoCode%40yahoogroups.com> ] On Behalf Of Ved Prakash
              > Sent: Monday, March 05, 2007 9:07 AM
              > To: SQLQueriesNoCode@yahoogroups.com
              <mailto:SQLQueriesNoCode%40yahoogroups.com>
              > Subject: [SQLQueriesNoCode] How to delete repeated data from a table?
              >
              >
              >
              > Hi,
              >
              > I have a problem. How to delete repeated data from a table?
              > Can any body help me to out of the prob.
              >
              > Prob:
              > I have a table Table1. There is no primary key. There is
              > repeted data in the table1 e.g Table1 Data
              > ----------------------------------------------------------
              > Name Sal
              > ----------------------------------------------------------
              > A 3000
              > B 2000
              > B 2000
              > C 1000
              > C 1000
              > C 1000
              > A 3000
              > D 5000
              > B 2000
              > ----------------------------------------------------------
              > Now I have to write a query which will delete the repeated
              > data. As for this example Output should be
              >
              > ----------------------------------------------------------
              > Name Sal
              > ----------------------------------------------------------
              > A 3000
              > B 2000
              > C 1000
              > D 5000
              > ----------------------------------------------------------
              > Thanks in Adv.
              > Prakash
              >





              [Non-text portions of this message have been removed]
            • John Warner
              Happns to us all. I kept trying to figure out why the UI at 15seconds was so different, finally after several searches it dawned on me. John Warner
              Message 6 of 10 , Mar 5 4:39 PM
              • 0 Attachment
                Happns to us all. I kept trying to figure out why the UI at 15seconds
                was so different, finally after several searches it dawned on me.

                John Warner


                > -----Original Message-----
                > From: SQLQueriesNoCode@yahoogroups.com
                > [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Michael Weiss
                > Sent: Monday, March 05, 2007 6:55 PM
                > To: SQLQueriesNoCode@yahoogroups.com
                > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
                > from a table?
                >
                >
                > Ooh Good catch, John! Thanks! I didn't even notice the typo...
                >
                > Michael
                >
                >
                >
                > _____
                >
                > From: SQLQueriesNoCode@yahoogroups.com
                > [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of John Warner
                > Sent: Monday, March 05, 2007 3:06 PM
                > To: SQLQueriesNoCode@yahoogroups.com
                > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
                > from a table?
                >
                >
                >
                > Note it is:
                > www.15seconds.com
                >
                > Note the "o" between "c" and "n". Makes all the difference in
                > the world to the help you will get.
                >
                > The para-site is a waste of your time
                >
                > John Warner
                >
                > > -----Original Message-----
                > > From: SQLQueriesNoCode@yahoogroups.com
                > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                > > [mailto:SQLQueriesNoCode@yahoogroups.com
                > <mailto:SQLQueriesNoCode%40yahoogroups.com> ] On Behalf Of
                > Michael Weiss
                > > Sent: Monday, March 05, 2007 5:55 PM
                > > To: SQLQueriesNoCode@yahoogroups.com
                > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                > > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
                > > from a table?
                > >
                > >
                > > Try www.15secnds.com <http://www.15secnds.com/
                > <http://www.15secnds.com/> > - there is
                > > an article there by David Penton which covers deleting dupe records.
                > >
                > > Regards,
                > >
                > > Michael
                > >
                > >
                > >
                > > _____
                > >
                > > From: SQLQueriesNoCode@yahoogroups.com
                > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                > > [mailto:SQLQueriesNoCode@yahoogroups.com
                > <mailto:SQLQueriesNoCode%40yahoogroups.com> ] On Behalf Of Ved Prakash
                > > Sent: Monday, March 05, 2007 9:07 AM
                > > To: SQLQueriesNoCode@yahoogroups.com
                > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                > > Subject: [SQLQueriesNoCode] How to delete repeated data
                > from a table?
                > >
                > >
                > >
                > > Hi,
                > >
                > > I have a problem. How to delete repeated data from a table?
                > > Can any body help me to out of the prob.
                > >
                > > Prob:
                > > I have a table Table1. There is no primary key. There is
                > > repeted data in the table1 e.g Table1 Data
                > > ----------------------------------------------------------
                > > Name Sal
                > > ----------------------------------------------------------
                > > A 3000
                > > B 2000
                > > B 2000
                > > C 1000
                > > C 1000
                > > C 1000
                > > A 3000
                > > D 5000
                > > B 2000
                > > ----------------------------------------------------------
                > > Now I have to write a query which will delete the repeated
                > > data. As for this example Output should be
                > >
                > > ----------------------------------------------------------
                > > Name Sal
                > > ----------------------------------------------------------
                > > A 3000
                > > B 2000
                > > C 1000
                > > D 5000
                > > ----------------------------------------------------------
                > > Thanks in Adv.
                > > Prakash
                > >
              • my.yudis
                SELECT DISTINCT * INTO new_table FROM duplicated_table GO DROP TABLE duplicated_table GO SELECT DISTINCT * INTO duplicated_table FROM new_table GO DROP TABLE
                Message 7 of 10 , Mar 6 9:46 PM
                • 0 Attachment
                  SELECT DISTINCT * INTO new_table FROM duplicated_table
                  GO

                  DROP TABLE duplicated_table
                  GO

                  SELECT DISTINCT * INTO duplicated_table FROM new_table
                  GO

                  DROP TABLE new_table
                  GO

                  regards,
                  - jude -



                  On 05 Mar 2007 16:41:39 -0800, Ved Prakash <vedprakash4@...> wrote:
                  >
                  > > > Hi,
                  > > >
                  > > > I have a problem. How to delete repeated data from a table?
                  > > > Can any body help me to out of the prob.
                  > > >
                  > > > Prob:
                  > > > I have a table Table1. There is no primary key. There is
                  > > > repeted data in the table1 e.g Table1 Data
                  > > > ----------------------------------------------------------
                  > > > Name Sal
                  > > > ----------------------------------------------------------
                  > > > A 3000
                  > > > B 2000
                  > > > B 2000
                  > > > C 1000
                  > > > C 1000
                  > > > C 1000
                  > > > A 3000
                  > > > D 5000
                  > > > B 2000
                  > > > ----------------------------------------------------------
                  > > > Now I have to write a query which will delete the repeated
                  > > > data. As for this example Output should be
                  > > >
                  > > > ----------------------------------------------------------
                  > > > Name Sal
                  > > > ----------------------------------------------------------
                  > > > A 3000
                  > > > B 2000
                  > > > C 1000
                  > > > D 5000
                  > > > ----------------------------------------------------------
                  > > > Thanks in Adv.
                  > > > Prakash
                  > > >
                  > .
                  >
                  >
                  >


                  [Non-text portions of this message have been removed]
                • zeeshan khan
                  Why u want to delete the repating Column. Simple Used distinct keyword for the column. ... Don t pick lemons. See all the new 2007 cars at Yahoo! Autos.
                  Message 8 of 10 , Mar 7 1:05 AM
                  • 0 Attachment
                    Why u want to delete the repating Column. Simple Used distinct keyword for the column.


                    ---------------------------------
                    Don't pick lemons.
                    See all the new 2007 cars at Yahoo! Autos.

                    [Non-text portions of this message have been removed]
                  • BESHOUY GERGES
                    try select distinct Name Sal John Warner wrote: Happns to us all. I kept trying to figure out why the UI at 15seconds was so
                    Message 9 of 10 , Mar 7 8:16 AM
                    • 0 Attachment
                      try select distinct Name Sal

                      John Warner <john@...> wrote: Happns to us all. I kept trying to figure out why the UI at 15seconds
                      was so different, finally after several searches it dawned on me.

                      John Warner

                      > -----Original Message-----
                      > From: SQLQueriesNoCode@yahoogroups.com
                      > [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Michael Weiss
                      > Sent: Monday, March 05, 2007 6:55 PM
                      > To: SQLQueriesNoCode@yahoogroups.com
                      > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
                      > from a table?
                      >
                      >
                      > Ooh Good catch, John! Thanks! I didn't even notice the typo...
                      >
                      > Michael
                      >
                      >
                      >
                      > _____
                      >
                      > From: SQLQueriesNoCode@yahoogroups.com
                      > [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of John Warner
                      > Sent: Monday, March 05, 2007 3:06 PM
                      > To: SQLQueriesNoCode@yahoogroups.com
                      > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
                      > from a table?
                      >
                      >
                      >
                      > Note it is:
                      > www.15seconds.com
                      >
                      > Note the "o" between "c" and "n". Makes all the difference in
                      > the world to the help you will get.
                      >
                      > The para-site is a waste of your time
                      >
                      > John Warner
                      >
                      > > -----Original Message-----
                      > > From: SQLQueriesNoCode@yahoogroups.com
                      > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                      > > [mailto:SQLQueriesNoCode@yahoogroups.com
                      > <mailto:SQLQueriesNoCode%40yahoogroups.com> ] On Behalf Of
                      > Michael Weiss
                      > > Sent: Monday, March 05, 2007 5:55 PM
                      > > To: SQLQueriesNoCode@yahoogroups.com
                      > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                      > > Subject: RE: [SQLQueriesNoCode] How to delete repeated data
                      > > from a table?
                      > >
                      > >
                      > > Try www.15secnds.com <http://www.15secnds.com/
                      > <http://www.15secnds.com/> > - there is
                      > > an article there by David Penton which covers deleting dupe records.
                      > >
                      > > Regards,
                      > >
                      > > Michael
                      > >
                      > >
                      > >
                      > > _____
                      > >
                      > > From: SQLQueriesNoCode@yahoogroups.com
                      > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                      > > [mailto:SQLQueriesNoCode@yahoogroups.com
                      > <mailto:SQLQueriesNoCode%40yahoogroups.com> ] On Behalf Of Ved Prakash
                      > > Sent: Monday, March 05, 2007 9:07 AM
                      > > To: SQLQueriesNoCode@yahoogroups.com
                      > <mailto:SQLQueriesNoCode%40yahoogroups.com>
                      > > Subject: [SQLQueriesNoCode] How to delete repeated data
                      > from a table?
                      > >
                      > >
                      > >
                      > > Hi,
                      > >
                      > > I have a problem. How to delete repeated data from a table?
                      > > Can any body help me to out of the prob.
                      > >
                      > > Prob:
                      > > I have a table Table1. There is no primary key. There is
                      > > repeted data in the table1 e.g Table1 Data
                      > > ----------------------------------------------------------
                      > > Name Sal
                      > > ----------------------------------------------------------
                      > > A 3000
                      > > B 2000
                      > > B 2000
                      > > C 1000
                      > > C 1000
                      > > C 1000
                      > > A 3000
                      > > D 5000
                      > > B 2000
                      > > ----------------------------------------------------------
                      > > Now I have to write a query which will delete the repeated
                      > > data. As for this example Output should be
                      > >
                      > > ----------------------------------------------------------
                      > > Name Sal
                      > > ----------------------------------------------------------
                      > > A 3000
                      > > B 2000
                      > > C 1000
                      > > D 5000
                      > > ----------------------------------------------------------
                      > > Thanks in Adv.
                      > > Prakash
                      > >






                      ---------------------------------
                      Don't get soaked. Take a quick peek at the forecast
                      with theYahoo! Search weather shortcut.

                      [Non-text portions of this message have been removed]
                    • Michael Weiss
                      This approach would work on small recordsets in a heap and no joins. Regards, Michael _____ From: SQLQueriesNoCode@yahoogroups.com
                      Message 10 of 10 , Mar 7 9:24 AM
                      • 0 Attachment
                        This approach would work on small recordsets in a heap and no joins.

                        Regards,

                        Michael



                        _____

                        From: SQLQueriesNoCode@yahoogroups.com
                        [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of my.yudis
                        Sent: Tuesday, March 06, 2007 9:46 PM
                        To: SQLQueriesNoCode@yahoogroups.com
                        Subject: Re: [SQLQueriesNoCode] How to delete repeated data from a
                        table?



                        SELECT DISTINCT * INTO new_table FROM duplicated_table
                        GO

                        DROP TABLE duplicated_table
                        GO

                        SELECT DISTINCT * INTO duplicated_table FROM new_table
                        GO

                        DROP TABLE new_table
                        GO

                        regards,
                        - jude -

                        On 05 Mar 2007 16:41:39 -0800, Ved Prakash <vedprakash4@...
                        <mailto:vedprakash4%40yahoo.com> > wrote:
                        >
                        > > > Hi,
                        > > >
                        > > > I have a problem. How to delete repeated data from a table?
                        > > > Can any body help me to out of the prob.
                        > > >
                        > > > Prob:
                        > > > I have a table Table1. There is no primary key. There is
                        > > > repeted data in the table1 e.g Table1 Data
                        > > > ----------------------------------------------------------
                        > > > Name Sal
                        > > > ----------------------------------------------------------
                        > > > A 3000
                        > > > B 2000
                        > > > B 2000
                        > > > C 1000
                        > > > C 1000
                        > > > C 1000
                        > > > A 3000
                        > > > D 5000
                        > > > B 2000
                        > > > ----------------------------------------------------------
                        > > > Now I have to write a query which will delete the repeated
                        > > > data. As for this example Output should be
                        > > >
                        > > > ----------------------------------------------------------
                        > > > Name Sal
                        > > > ----------------------------------------------------------
                        > > > A 3000
                        > > > B 2000
                        > > > C 1000
                        > > > D 5000
                        > > > ----------------------------------------------------------
                        > > > Thanks in Adv.
                        > > > Prakash
                        > > >
                        > .
                        >
                        >
                        >

                        [Non-text portions of this message have been removed]





                        [Non-text portions of this message have been removed]
                      Your message has been successfully submitted and would be delivered to recipients shortly.