Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Partial string comparison in DECODE ?

Re: Partial string comparison in DECODE ?

From: Pierre Charpenay <pcharpenay_at_unilog.fr>
Date: Fri, 22 Oct 1999 13:37:07 +0200
Message-ID: <38104C63.2955930E@unilog.fr>

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US