question:
How to determint wether two column equals?
Answer:
Table one:RecordId = 1,CommonId = 5,Approved = 1.
RecordId = 2,CommonId = 5 Approved = 0.
Table two:RecordId = 4,
CommonId = 9,
Approved = 1.
case one:if you are compare in the one table.
you can use the following code
select commonId, (case when max(Approved) = min(Approved) then 1 else 0 end) as IsEqual from MyTable A group by commonId;
case two:if you are compare in the two tables.
you can use the following code.
SELECT CASE WHEN (A.Approved = B.Approved) THEN 1 ELSE 0 END FROM MyTable A, MyTable B WHERE A.commonId = B.commonId;
Note:you need modify condition A.Approved = B.Approved only ,in compare two tables different column.