Re: [SQL] sort for ranking

2003-07-09 Thread Henshall, Stuart - TNP Southwest
Title: RE: [SQL] sort for ranking Could you do something like the following: SELECT sum_user,(SELECT count(sum_user)+1 FROM tbl_sums AS t WHERE t.sum_user>tbl_sums.sum_user) AS ranking FROM tbl_sums ORDER BY ranking hth, - Stuart P.S. Sorry about format change, the disclaimer adder forces

Re: [SQL] sort for ranking

2003-07-07 Thread scott.marlowe
I'm gonna guess you stored your ranking as a "text" field, but now you'd like to treat it like an int / numeric. While it would be better to go ahead and convert it, you can always cast it: select * from table order by textfield::int; On Mon, 7 Jul 2003, Andreas Schmitz wrote: > > Hello *, >

Re: [SQL] sort for ranking

2003-07-07 Thread Jean-Luc Lachance
Andreas, try select sum_user,nextval('tipp_eval_seq')-1 as ranking from ( select user_sum from tbl_sums order by user_sum desc) as ss; JLL Andreas Schmitz wrote: > > Hello *, > > I have a little problem that confuses me. We are gathering values from a table > as a sum to insert them into

[SQL] sort for ranking

2003-07-07 Thread Andreas Schmitz
Hello *, I have a little problem that confuses me. We are gathering values from a table as a sum to insert them into another table. I also need to get a ranking at insert (i.e. Highest points will get first place and so on). I tried ton invole a sequence to qualify the ranking by select at ins