Quote:
Originally posted by mark_tim1999
Can anyone help in DB2 SQL?
DEPT_ID(CHAR data type)
2000
2100
2200_ABC
2300_CDE
2400_FGH
I need only numerics to be displayed(all characters aftre underscore should be truncated)?TRUNCATE does'nt work.
|
SUBSTR(DEPT_ID,1,5)
or
CASE
LOCATE(DEPT_ID, '_')
WHEN 0
DEPT_ID
ELSE
SUBSTR(DEPT_ID, 1, LOCATE(DEPT_ID, '_'))
END