Re: How to filter zeroes in select statements

From: David Rackley <drack_at_sbctri.sbc.com>
Date: 1996/05/29
Message-ID: <9b689fwsbf.fsf_at_diablo.tri.sbc.com>#1/1


In article <4ofrd3$8c_at_client2.news.psi.net> Neal Gran <neal_at_anisoft.com> writes:

> I am trying to code a select statement in which one numeric field may
> take a value from one of two sources, s1 and s2. The condition is whether
> s1 is zero or not. I need something like the 'nlv' function,
> except for a zero value of s1 instead of a null value. I haven't found
> anything helpful in the Oralce SQL manual. Does anyone have any
> suggestions for this problem?

Try using the decode function, eg.

   select decode(col1,0,s1,s2) from your_table;

..dave

-- 

  +----------------------+----------------------------------------------+
  | David Rackley        | email: drack_at_tri.sbc.com                     |
  | Southwestern Bell    |   tel: (512) 372-5516  FAX: (512) 372-5591   |
  | Technology Resources |  http://www.tri.sbc.com/                     |
  | 9505 Arboretum Blvd  +----------------------------------------------+
  | Austin, TX 78759     | It's OK to be a martyr, as long as you don't |
  |                      | bring your own firewood.  -- Dr. Jim Rigby   |
  +----------------------+----------------------------------------------+   
Received on Wed May 29 1996 - 00:00:00 CEST

Original text of this message