Home Forums SQL Server 2005 T-SQL (SS2K5) find out which record_ids match on 2 fields and not match a third field. RE: find out which record_ids match on 2 fields and not match a third field.

  • End result is a report show the type for each row.

    tempcheck_idRECORD_IDItemI_descS_descM_descStatus_Flag

    1 1 123 desc blue rg Type1

    2 1 124 desc blue rg Type1

    3 1 125 desc blue rg Type1

    4 2 123 desc blue rg Type2

    5 2 123 desc blue rg Type2

    6 2 123 desc blue rg Type2

    7 3 123 desc blue rg Type2

    8 3 123 desc blue rg Type2

    9 3 123 desc blue rg Type2

    10 3 123 desc blue rg Type2

    11 4 123 desc2 blue rg Type3

    12 4 123 desc2 blue rg Type3

    13 4 123 desc3 blue rg Type3

    14 4 123 desc3 blue rg Type3

    Where Type1 I_desc and M_desc match and Item is not, for same for record_Id.

    Where Type2 I_desc and M_Desc and Item all match for same record_ID.

    Where Type3 I_desc is not matched and M_Desc and Item are matched, for same record_id.