New to SQL, so please accept my apologies. A query was created that when
If HBL_CLNT_CAT._HS_EB_CODE1 = 'BF' then value = TBM_BILLGRP._HS_EB_DET1
If HBL_CLNT_CAT._HS_EB_CODE2 = 'BF' then value = TBM_BILLGRP._HS_EB_DET2
However of the _HS_EB_DET# exceeds 100 characters add a ‘*’.
With assistance a query was developed, however it broken the condition rules in that the ‘then statement/action would fail because it was greater number than the condition statement (select _hs_eb_code1 from hbl_cat where hs_eb_code = 'bf' that returns only 1 record).
select
case when len(format) > 100
then left(format, 100) + '*'
else format
end as format
from
( select
case when exists ( select _hs_eb_code1
from hbl_cat
where hs_eb_code = 'bf'
)
then tbm_bllgrp._hs_eb_det1
end
) as format
from tbm_bllgrp
Formatting the code would have helped you find the error. Try this: