Thanx this will work . My web host has PostgreSQL  installed I can get a DB
from there.

By the way is PostgreSQL  free and if yes where can I get a copy to practise
myself.
________________________________________
Rakhitha Karunarathne
Web Master
www.Ad-Man.tk - Free Unlimited Banner Rotators
________________________________________



----- Original Message ----- 
From: "Randal L. Schwartz" <[EMAIL PROTECTED]>
To: "LRMK" <[EMAIL PROTECTED]>
Sent: Friday, May 21, 2004 9:24 PM
Subject: Re: A MySQL Question


> If you have an actual database (not MySQL, but something modern like
> PostgreSQL or Oracle), you can solve this with a simple subselect and
> self join.  Not the most efficient, but probably more efficient than a
> lot of roundtrips to the Perl side.
>
> For mytable which has "rank" and "score" where you want "rank" to reflect
> ranking where "score" is highest, use:
>
>     UPDATE mytable
>     SET rank = (
>       SELECT 1+count(*)
>       FROM mytable AS b
>       WHERE b.score > mytable.score
>     );
>
> This has the cool feature that ties are automatically assigned the
> same value.  For example:
>
>  rank | score
> ------+-------
>     6 |    10
>     5 |    20
>     3 |    30
>     3 |    30
>     2 |    40
>     1 |    50
>
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
> <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to