Re: Creating a Rank Value

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 07/03/04


Date: Sat, 3 Jul 2004 15:42:59 -0400


> update table
> set @rank=rank=case
> when @groupvalue <> groupvalue then 1
> when @scoringvalue < scoringvalue then @rank + 1
> else @rank
> end
> , @groupvalue = groupvalue, @scoringvalue = scoringvalue
> from table

Why do you need to store this rank? Do you really want to run this UPDATE
statement every single time the table is updated? Wouldn't it make more
sense to generate the ranks at runtime (since they can be calculated by data
in the table), as opposed to storing them perpetually?

-- 
http://www.aspfaq.com/
(Reverse address to reply.)


Relevant Pages

  • RE: Ranking group report with thresholds HELP umm sorry
    ... start a different store layout differently. ... Or you could just keep the rank ... [Other Qualifier] ... tblStoreDisplayLayout ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Ranking group report with thresholds HELP umm sorry
    ... start a different store layout differently. ... Or you could just keep the rank ... [Other Qualifier] ... tblStoreDisplayLayout ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Ranking different groups in one column
    ... As you see, three regions, a bunch of store names and scores. ... You can use this until some gives you a more compact solution. ... Gary''s Student - gsnu200776 ... a.n.other user from this datasheet and just 'pulling' the rank no into the ...
    (microsoft.public.excel.misc)
  • RE: Ranking different groups in one column
    ... As you see, three regions, a bunch of store names and scores. ... Gary''s Student - gsnu200776 ... a.n.other user from this datasheet and just 'pulling' the rank no into the ... sorting as the end user won't see the original data (the data is subject to ...
    (microsoft.public.excel.misc)
  • RE: Challenging SQL Query
    ... Perhaps the first idea that comes to my mind is a rank and tally. ... S.StorePrimaryKey) AS GroupOfThreeCounter, ... 0 Store 1 ... MAX(iif(= 0, [StoreName], null)) AS StoreA, ...
    (microsoft.public.access.queries)