retrieve duplicates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hganta
    New Member
    • Oct 2007
    • 6

    retrieve duplicates

    Hai,

    I am having a table with name product_tbl wherin two columns exists productname and productgroup. Can u please give me a query wherin i can retrieve values of same in the two columns.

    Thanks
  • azimmer
    Recognized Expert New Member
    • Jul 2007
    • 200

    #2
    Originally posted by hganta
    Hai,

    I am having a table with name product_tbl wherin two columns exists productname and productgroup. Can u please give me a query wherin i can retrieve values of same in the two columns.

    Thanks
    Code:
    SELECT productname
    FROM product_tbl
    WHERE productname=productgroup

    Comment

    • hganta
      New Member
      • Oct 2007
      • 6

      #3
      Originally posted by azimmer
      Code:
      SELECT productname
      FROM product_tbl
      WHERE productname=productgroup
      HI,

      Thanks for ur response

      But my query is not for the same row in the columns. The productname of one row will be matched with another row of the productgroup in the table product_tbl. Can u please give me the extended one....

      Thanks

      Comment

      • hganta
        New Member
        • Oct 2007
        • 6

        #4
        retrieve duplicates

        HI,

        I have a table product_tbl in which two columns exists. productname and productgroup. The productname of one row will be matched with another row of the productgroup in the table product_tbl. Can u please give me the query on this one....

        Thanks

        Comment

        • azimmer
          Recognized Expert New Member
          • Jul 2007
          • 200

          #5
          Originally posted by hganta
          HI,

          Thanks for ur response

          But my query is not for the same row in the columns. The productname of one row will be matched with another row of the productgroup in the table product_tbl. Can u please give me the extended one....

          Thanks
          You mean it's like this:

          Product Productgroup
          A Something
          ... ...
          B A
          ... ...

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #6
            both the threads a re merged.

            Comment

            • iburyak
              Recognized Expert Top Contributor
              • Nov 2006
              • 1016

              #7
              You should show example of data and desired result.
              By your brief description it is hard to tell what is requested.

              Thank you.

              Comment

              • jamesd0142
                Contributor
                • Sep 2007
                • 471

                #8
                Originally posted by hganta
                Hai,

                I am having a table with name product_tbl wherin two columns exists productname and productgroup. Can u please give me a query wherin i can retrieve values of same in the two columns.

                Thanks
                SELECT <columnName>
                COUNT(<columnNa me>) AS NumOccurrences
                FROM <databasename >
                GROUP BY <columnName>
                HAVING (COUNT(<columnN ame>)>1)

                Comment

                • Motoma
                  Recognized Expert Specialist
                  • Jan 2007
                  • 3236

                  #9
                  Originally posted by hganta
                  Hai,

                  I am having a table with name product_tbl wherin two columns exists productname and productgroup. Can u please give me a query wherin i can retrieve values of same in the two columns.

                  Thanks
                  Hi Hganta,
                  I hope you have found the responses in this thread useful. If you still have not received an answer which performs the task you are looking for, please consider giving us a sample data set along with the result you are looking to get from it.

                  Comment

                  • hganta
                    New Member
                    • Oct 2007
                    • 6

                    #10
                    Product Productgroup
                    XYZ ABC
                    ... ...
                    MNK XYZ

                    s exactly that is what i mean.

                    please provide me the query on this.

                    I want to retrive the XYZ cases both in product and productgroup.

                    Comment

                    • iburyak
                      Recognized Expert Top Contributor
                      • Nov 2006
                      • 1016

                      #11
                      To find duplicates in a table do following:

                      select productname, productgroup, count(*)
                      from product_tbl
                      group by productname, productgroup
                      having count(*) > 1

                      Good Luck.

                      Comment

                      Working...