SELECTMIN(COALESCE(cmp_values(parent_td.value, parent_md.value, parent_cmp.value),0)) as chk_parent,FROM some_table
having chk_parent > 0
ERROR: column "chk_parent" does not exist at character 2342