you can use CASE
WHEN
as follow as achieve the as IF
ELSE
.
SELECT FROM A a
LEFT JOIN B b
ON a.col1 = b.col1
AND (CASE
WHEN a.col2 like '0%' then TRIM(LEADING '0' FROM a.col2)
ELSE substring(a.col2,1,2)
END
)=b.col2;
p.s:just in case somebody needs this way.