Re: olympics ranking query - Mailing list pgsql-sql

From David Garamond
Subject Re: olympics ranking query
Date
Msg-id 412630C8.5000004@zara.6.isreserved.com
Whole thread Raw
In response to Re: olympics ranking query  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: olympics ranking query  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Tom Lane wrote:
>>Challenge question: is there a simpler way to do query #1 (without any 
>>PL, and if possible without sequences too?
> 
> Can't without sequences AFAIK, but you certainly can do it simpler:
> 
> select setval('seq1', 0);
> 
> select nextval('seq1'), * from
> (select count(*) as numranker,
>  gold, silver, bronze
>  from countrymedal
>  group by gold, silver, bronze
>  order by gold desc, silver desc, bronze desc) ss;

This is not quite the same. The ranks are sequential, but they skip, so 
as to match the number of participating countries.

-- 
dave


pgsql-sql by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: olympics ranking query
Next
From: Tom Lane
Date:
Subject: Re: olympics ranking query