pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Garamond <lists@zara.6.isreserved.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: olympics ranking query
Date: Sat, 21 Aug 2004 00:11:36 +0700
Message-ID: <412630C8.5000004@zara.6.isreserved.com> (raw)
In-Reply-To: <22979.1093020382@sss.pgh.pa.us>
References: <41262968.2000507@zara.6.isreserved.com>
	<22979.1093020382@sss.pgh.pa.us>

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



view thread (8+ messages)  latest in thread

Message-ID: <412630C8.5000004@zara.6.isreserved.com>
Permalink:  ../412630C8.5000004@zara.6.isreserved.com/
Also on:    postgresql.org/message-id/412630C8.5000004@zara.6.isreserved.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@zara.6.isreserved.com, tgl@sss.pgh.pa.us
  Subject: Re: olympics ranking query
  In-Reply-To: <412630C8.5000004@zara.6.isreserved.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox