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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Need Help for an intelligent query

Re: Need Help for an intelligent query

From: Paul <aspscott_at_tcp.co.uk>
Date: 2000/05/02
Message-ID: <8vlugs0mb0ec57i7o1sntfcs424m6mpsgg@4ax.com>#1/1

On Wed, 3 May 2000 00:09:09 +0200, "Julien Bellorgey" <jbellorg_at_easynet.fr> wrote:

>Hello,
>
>Maybe this question will seem too easy to answer, but is there a way to
>create a query that can generate values depending on the values of other
>fields (an example is provided).
>I know how to do it with Access, but I do not know with Oracle 7.
>Thank you very much if somebody can help me.
>
>Regards,
>
>Julien
>
>-------------------------------------
>For example:
>
>Table A
>
>Name, Age, Points
>Jim 25 150
>Joe 20 300
>Scott 30 500
>
>For each person, the query must indicate if the points are more than 200 or
>not.
>The result of the query must be :
>
>Jim No
>Joe Yes
>Scott Yes
>
>

Try this :

select
  Name,
  Decode(Sign(Points - 200), 1, 'Yes', 'No') from
  TableA

Sign function returns :
-1 if value is less than 0
 0 if value = 0
 1 if value is greater than 0

Decode function is effectively an if...then...else for SQL

Hope this helps.

Paul Received on Tue May 02 2000 - 00:00:00 CDT

Original text of this message

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