How do I compare two columns for equality in SQL Server?

后端 未结 7 1030
忘掉有多难
忘掉有多难 2020-12-06 04:15

I have two columns that are joined together on certain criteria, but I would also like to check if two other columns are identical and then return a bit field if they are.

7条回答
  •  不思量自难忘°
    2020-12-06 04:33

    The use of IIF? And it depends on version of SQL Server.

    SELECT
    IIF(Column1 = Column2, 1, 0) AS MyDesiredResult
    FROM Table;
    

提交回复
热议问题