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: DIfferential sign

Re: DIfferential sign

From: Jan Gelbrich <j_gelbrich_at_westfalen-blatt.de>
Date: Mon, 1 Sep 2003 15:05:03 +0200
Message-ID: <bivga7$dqjhu$1@ID-152732.news.uni-berlin.de>

"Prasad Kulkarni" <prasad.kulkarni_at_mailcity.com> schrieb im Newsbeitrag news:a8274029.0309010415.25861292_at_posting.google.com...
> Hello All,
>
> I have a table in which there are two fields for
> quantity(table1_qty1 and table1_qty2) and one field(table1_diffsign)
> for differential sign between the two quantiies. Now i want to write a
> query to set the field table1_diffsign = 1 if table1_qty1 >=
> table1_qty2 and table1_diffsign = -1 if table1_qty1 < table1_qty2.
>
> I thought of doing
> table_diffsign = (table1_qty1 - table1_qty2) / ABS((table1_qty1 -
> table1_qty2))
> But it will give an error if table1_qty1 = table1_qty2.

Obviously, division by zero must be excluded, so just add to the WHERE clause:
-> Select ... Where ... AND table1_qty1 != table1_qty2

>
> Does somebody know how can i achive it in a single query?
> Thanks in advance..
>
> Regards
> Prasad
Received on Mon Sep 01 2003 - 08:05:03 CDT

Original text of this message

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