Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL-sentence
Jon,
given this table...
SQL> select * from foo;
FIELD
1 -1
on oracle 8i and up you can do this...
SQL> select case
2 when field > 0 then field - 5000 3 else field 4 end field
FIELD
-4999 -1
on older version of oracle, you can do this
SQL> select decode( greatest( field, 0 ), 2 field, field-5000, field ) field 3 from foo;
FIELD
-4999 -1
hope this helps.
chris.
-- Christopher Beck, Principal Technologist, Oracle Corporation christopher.beck_at_oracle.com Beginning Oracle Programming, http://www.amazon.com/exec/obidos/ASIN/186100690X "Jon Ole Hedne" <johedne_at_online.no> wrote in message news:4QPI8.6628$fG3.228341_at_news2.ulv.nextra.no...Received on Tue May 28 2002 - 14:01:20 CDT
> I want to list numbers in a column in this way:
>
> If Field > 0, Field - 5000, Else Field
>
> How can I solve this with a SQL-sentence?
>
> Jon Ole Hedne
> Norway
>
>
![]() |
![]() |