Select Rows with matching columns from SQL Server

前端 未结 3 966
一向
一向 2020-12-11 15:04

I am fairly certain that this is something simple, but every example I have tried is failing. I want to query a table like this

ID   Part_Type   Station_Typ         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-11 15:35

    select id, part_type, station_type 
    from myTable t1
    where exists (select 1 from myTable t2
                  where t1.part_type = t2.part_type
                      and t1.station_type = t2.station_type
                      and t1.id <> t2.id)
    

提交回复
热议问题