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: Sum on like wildcard - replacing decode statement

Re: Sum on like wildcard - replacing decode statement

From: Andy Hassall <andy_at_andyh.co.uk>
Date: Wed, 08 Jun 2005 20:59:36 +0100
Message-ID: <iejea11r497q1bi0ut35g8poduen7lu7b5@4ax.com>


On 8 Jun 2005 12:47:51 -0700, bbcrock_at_gmail.com wrote:

>I need to replace a decode statement with some other process.
>
>currently the old DBA's code reads:
>sum(decode(status 'PENDING', 1, 0)) PENDING
>
>We added several new "PENDING" entries. I need to rewrite it as:
>sum(decode(status 'PENDING%', 1, 0)) PENDING
>
>decode fails here. Does anyone have a working example of a case
>statement or similar code?

 The CASE statement is more flexible, and it's also more "standard".

sum(
 case
  when status like 'PENDING%' then 1
  else 0
 end
) PENDING

-- 
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Received on Wed Jun 08 2005 - 14:59:36 CDT

Original text of this message

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