You're correct, when you do a calculation on the PI column the value might change resulting in the need to redistribute based on the new hash.
When you move the calculation into a Derived Table you still need to calculate the new hash.
Deopending on what you try to achieve moving the CASE from the join condition to the select list might help:
SELECT
CASE WHEN H.col1 LIKE 'X%'
OR H.col1 IS NULL THEN 'NO NUMBER'
ELSE H.col1
END
FROM table1 A
LEFT OUTER JOIN table2 H
ON A.col1 = H.col1
AND A.col2 = H.col2
Dieter
↧