Select Case query not working
New to SQL and in the process of developing query, with the to replicate part of an ETL process.
A billing code1 = bf, is then set to debt code 1. If billing field (debt code) exceeds 100 characters then add '*' as prefix.
However query will fall down because billing code1 = bf returns a single resultset to a debt code1 that returns large resultset.
select
case when len(format) > 100 then left(format, 100) + '*'
else forma开发者_运维知识库t 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
Ideas welcomed.
select
case when len(format) > 100 then left(format, 100) + '*'
else format end as format
from tbm_bllgrp b
inner join hbl_cat hc on hc._hs_eb_code1 = b._hs_eb_det1
This is just a guess since I don't have your exactl schema and expected output, but I hope this gives you some ideas
精彩评论