Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f2CJwxx55040 for ; Mon, 12 Mar 2001 14:58:59 -0500 (EST) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f27IUAx07721 for ; Wed, 7 Mar 2001 13:30:10 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f27I77H93833 for pgsql-sql@postgresql.org; Wed, 7 Mar 2001 13:07:07 -0500 (EST) (envelope-from news) From: "Kevin T. Manley \(Home\)" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: SQL problem Date: Wed, 7 Mar 2001 10:12:18 -0800 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 35 Message-ID: <985tca$2rk6$1@news.tht.net> References: <3AA6445B.F409966F@yahoo.com> X-Complaints-To: scrappy@hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 To: pgsql-sql@postgresql.org X-Archive-Number: 200103/228 X-Sequence-Number: 1882 Here's one approach: create view vw_maxrain as select max(rain) as rain, date_part('year',day) as year from meteo group by year; select day, meteo.rain from meteo, vw_maxrain where meteo.rain=vw_maxrain.rain; "Salvador Mainé" wrote in message news:3AA6445B.F409966F@yahoo.com... > Hello: > > I have a table with pluviometrical data > > meteo (rain float, day date) > > I want to select the the day of maximum value for each year.It should be > something like : > > > select max(rain),day from meteo group by date_part('year', day); > > > but it obiously doesn't work. > I thought of doing it with aggregates, but it's far too complicated. Is > there an 'easy' way to do this? > > > > > -- > Salva