David Garamond <lists@zara.6.isreserved.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, bronzefrom countrymedalgroup by gold, silver, bronzeorder by gold desc,
silverdesc, bronze desc) ss;
regards, tom lane