[SQL] I need an aggregate with 2 parameters

2001-03-12 Thread Salvador Mainé
Hello: I have a table with pluviometrical data meteo (rain float, day date, oid station) I want to select the the day of maximum value for each year for a given measurement station. It should look like : select max(rain),day from meteo group by date_part('year', day) where station=7654765; th

Re: [SQL] I need an aggregate with 2 parameters

2001-03-12 Thread Michael Fork
This should work: SELECT day, rain FROM meteo WHERE rain = (SELECT max(rain) FROM meteo WHERE date_part('year', day) = '2001') Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access - Toledo Ohio On Thu, 8 Mar 2001, Salvador [iso-8859-1] Mainé wrote: > Hello: > > I have a tab

Re: [SQL] I need an aggregate with 2 parameters

2001-03-12 Thread Tom Lane
Salvador =?iso-8859-1?Q?Main=E9?= <[EMAIL PROTECTED]> writes: > I want to select the the day of maximum value for each year for a given > measurement station. This is exactly the sort of thing that SELECT DISTINCT ON is meant for. See the "weatherReports" example in the SELECT man page, http://ww