SELECT TYPE_PAR_NO, TYPE_PAR_NAME, CAST((CASE WHEN '{0}' = '' THEN 0 ELSE (CASE WHEN TYPE_PAR_NO IN (SELECT TYPE_PAR_NO FROM FAMS.TB_SUPPLIER_INFO_DTL WHERE SUP_SN = '{0}') THEN 1 ELSE 0 END) END) AS BIT) AS CHECKED_NO
FROM FAMS.TB_TYPE_PARENT_INFO
SELECT TYPE_PAR_NO, TYPE_PAR_NAME, case when t.TYPE_PAR_NO is null then 0 else 1 end AS CHECKED_NO
FROM FAMS.TB_TYPE_PARENT_INFO s left TB_SUPPLIER_INFO_DTL t on s.TYPE_PAR_NO=t.TYPE_PAR_NO