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: Looking for a solution

Re: Looking for a solution

From: Conan <conan_at___no-spam__dublin.com>
Date: Fri, 1 Dec 2000 11:15:36 -0000
Message-ID: <xNLV5.2316$Er5.1445@news.indigo.ie>

Hi Marco,
If you are using Oracle 8i or above (which supports order by in an inline view ) you can do something like this

select 12 -(rownum * 2) points,Track
from

   (select

           track
   from table1 order by time)
order by track

If not you will have to do something like this

select 12 - (pos *2 ) points , track
from

    (select

        a.track,
        count(b.num2) pos
    from
        table1 a,
        table b

    where a.time >= b.time
    group by

        a.Track)
order by Track

hth

Conan

Marco Juliano wrote in message <3A281BF7_at_MailAndNews.com>...
>Hello,
>
>I'm on beginner level of SQL and PL/SQL. I have a problem I can't solve, I
>hope anyone of you can help me.
>
>I got a table:
>
>TRACK TIME
>1 10
>2 20
>3 15
>4 13
>
>Now I have to create a PL/SQL script (I think) that gives points to the
>lowest
>time and up. For example the fastest time gets 10 points, the 2nd time gets
>8
>points etc. How can I use a PL/SQL script or some to generate a view of
>this?
>Goal:
>
>TRACK POINTS
>1 8
>2 2
>3 4
>4 6
>
>Many thanks in advance,
>
>Marco Juliano
>
Received on Fri Dec 01 2000 - 05:15:36 CST

Original text of this message

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