I'm trying to remove blank spaces that appear in a CHAR column within DB2. I received some helped here with the function TRANSLATE
to determine if Left
contained records that began with three letters:
select pat.f1, hos.hpid, hos.hpcd
from patall3 pat
join hospidl1 hos on pat.f1=hos.hpacct
where TRANSLATE(
LEFT( hos.hpid, 3 ),
'AAAAAAAAAAAAAAAAAAAAAAAAA',
'BCDEFGHIJKLMNOPQRSTUVWXYZ'
) <> 'AAA'
order by pat.f1;
But as you can see in my screenshot, there are records that remain, presumably because they begin with a blank space. I tried cast (hos.hpid as varchar)
but that doesn't work. Is it possible to trim these blank spaces?
Thanks,