Skip site navigation (1) Skip section navigation (2)

Re: olympics ranking query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: olympics ranking query
Date: 2004-08-20 16:46:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com> writes:
> 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;

			regards, tom lane

In response to


pgsql-sql by date

Next:From: Bruno Wolff IIIDate: 2004-08-20 17:01:48
Subject: Re: olympics ranking query
Previous:From: David GaramondDate: 2004-08-20 16:40:08
Subject: olympics ranking query

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group