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: SQL Query Question

Re: SQL Query Question

From: <bwally_at_ipass.net>
Date: Thu, 16 Apr 1998 22:03:21 GMT
Message-ID: <35367FF6.193A@ipass.net>


bwally_at_ipass.net wrote:
>
> Maybe you know how to do this, I can't remember. I have a table like
> this
>
> Week PersonID WeeksSalary
> 1 5571 1200.00
> 1 6001 1575.00
> 1 733 2400.00
> 2 5571 1350.00
> 2 6001 1000.00
> 2 733 2000.00
> 3 6001 1800.00
> 3 5571 1500.00
> 3 733 1000.00
>
> I want to retrieve the sum(WeeksSalary) grouped by personId and sorted
> such that I get a ranking printed, so:
>
> Ranking PersonId TotalSalary
> 1 733 5400
> 2 6001 4325
> 3 5571 4050
> 4 1111 2010
> etc.
>
> I know how to get personId TotalSalary
>
> Select personId, sum(WeeksSalary) TotalSalary
> >From myTable
> Group By personID
>
> How might I get a numeric ranking in for each record?
>
> Mike Wallach

PS.
What I am trying to do is build a query that: 1) let's me look at the top X entries. I cna do this using a INDX_DESC hint and rownum if I don't disable the index with the SUM()

2) Possibly create a view where I can find a particluar rank for a personID. So if I query with personID 6001 I can see his/her ranking is 3. Received on Thu Apr 16 1998 - 17:03:21 CDT

Original text of this message

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