COGNOiSe.com - The IBM Cognos Community

Legacy Business Intelligence => COGNOS ReportNet => Topic started by: Gooch on 04 Jan 2006 10:45:44 AM

Title: [Solved] Ranking Grouped Data
Post by: Gooch on 04 Jan 2006 10:45:44 AM
Hello.

I have a table as follows :-

REGIONÃ,  Ã, RANKÃ,  Ã, BRANCHÃ,  Ã,  Ã, SALES
NorthÃ,  Ã,  Ã,  1Ã,  Ã,  Ã,  Ã,  Ã,  GlasgowÃ,  Ã,  30000
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 4Ã,  Ã,  Ã,  Ã,  Ã,  AberdeenÃ,  10000
SouthÃ,  Ã,  Ã,  2Ã,  Ã,  Ã,  Ã,  Ã,  BristolÃ,  Ã,  Ã,  Ã,  25000
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 3Ã,  Ã,  Ã,  Ã,  Ã,  LondonÃ,  Ã,  Ã,  15000

I need to rank this by Sales within each region....any ideas of the required expression for this?

Gooch.Ã, 
Title: Re: Ranking Grouped Data
Post by: bdybldr on 04 Jan 2006 11:45:01 AM
Gooch,
Try changing your rank calculation to:

Rank([SALES] for Region).  This will give you ranking within each region. 

Hope this helps.  Keep us posted.
Title: Re: Ranking Grouped Data
Post by: johnsoncognos on 04 Jan 2006 03:13:57 PM
order by sales descending and rank from there. 

If you want a top 10 type thing try the following SQL


select * from
(select
  region,
  branch,
  sum(sales) as sales
from some_table
  group by
     region,
    branch
  order by sum(sales)  desc)
where rownum < 10