Select Rows with matching columns from SQL Server

前端 未结 3 969
一向
一向 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:40

    I think a self-join will work for you:

    SELECT * FROM table t1 
    INNER JOIN table t2 ON t1.Part_Type = t2.Part_Type 
      AND t1.Station_Type = t2.Station_Type
      AND t1.Id <> t2.Id
    

提交回复
热议问题