none
How to identify records with same values except some fields in one table? RRS feed

  • Question

  • Hi

    I've one table with many fields.

    When I did a SELECT statement for one record based on one filter condition it has given 3 records. when we look at these 3 records, all the field values for these 3 records are same except 2 fields.

    Now, I want to identify what are all the records have same values except those 2 fields.

    Could you please help me in achieving this.

    Thanks in advance.

    Monday, August 13, 2012 8:33 AM

Answers

  • If the repetition is in one column then you can use group by clause to identify the number of occurances of fied values and based on that you will get rows with similar fields.

    Example.

    select OrganizationLevel, count(*) from [HumanResources].[Employee]
    group by OrganizationLevel

    share your colums name in case you need more help...
    • Marked as answer by SQL2012BI Monday, August 13, 2012 8:52 AM
    Monday, August 13, 2012 8:44 AM