Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Partial string comparison in DECODE ?
fumi wrote :
>
> The comprasion in DECODE is more complicate and un-intuitive:
>
> DECODE(substr(dept_nbr, 1, 4),
> 'T791', 'Management',
> 'T792', 'Second Level',
> DECODE(substr(dept_nbr, 1, 5),
> 'T7922','Other', .....))
If dept_nbr is like 'T7922%' do this DECODE return 'Second Level' or 'Other' ...
?
To be more accurate, you'd better to write :
DECODE(SUBSTR(dept_nbr, 1, 4),
'T791', 'Management', 'T792', DECODE(SUBSTR(dept_nbr,1,5), 'T7922', 'Other', ... , ..., 'Second Level'), /* for T972 */ ... , ..., 'Unknown')
But using a user defined function would be probably a better solution.
Good Luck !
Pierre Received on Fri Oct 22 1999 - 06:37:07 CDT