How to find same data for all the columns in a table

  • I have a table with 10 to 12 columns, I am trying to find duplicate record for all the columns , I mean data should be same for all the columns.

    Any one let me know the query?

  • Can you post the DDL (create table) script, sample data as an insert statement and the expected output please?
    😎

  • the classic way would be to use GROUP BY HAVING count >  1

    SELECT
    Col1,Col2,Col3,Col10Or12
    FROM
    YourTable
    GROUP BY Col1,Col2,Col3C,Col10Or12
    HAVING COUNT(*) > 1

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell - Friday, January 20, 2017 1:04 PM

    the classic way would be to use GROUP BY HAVING count >  1

    SELECT
    Col1,Col2,Col3,Col10Or12
    FROM
    YourTable
    GROUP BY Col1,Col2,Col3C,Col10Or12
    HAVING COUNT(*) > 1

    And if you want to delete these duplicates, use one of the Row_Number() techniques mentioned here.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 4 posts - 1 through 3 (of 3 total)

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