How do i compare 2 rows from the same table (SQL Server)

后端 未结 6 567
太阳男子
太阳男子 2020-12-02 16:15

I need to create a background job that processes a table looking for rows matching on a particular id with different statuses. It will store the row data in a string to comp

6条回答
  •  一整个雨季
    2020-12-02 16:38

    OK, after 2 years it's finally time to correct the syntax:

    SELECT  t1.value, t2.value
    FROM    MyTable t1
    JOIN    MyTable t2
    ON      t1.id = t2.id
    WHERE   t1.id = @id
            AND t1.status = @status1
            AND t2.status = @status2
    

提交回复
热议问题