select contract_code,
case when contract_code is null then '0'
when contract_code='' then '0' else contract_code end as 判断后的合同编号
from 表名称