From: | Salvador Mainé <salvamaine(at)yahoo(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | I need an aggregate with 2 parameters |
Date: | 2001-03-08 09:31:19 |
Message-ID: | 3AA75167.68073235@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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;
though it obiously doesn't work.
I think that an aggregate function would be the best way to do this,
because the table is quite large and I need indexes for date and also
for stations, so adding a new one for the rain is too much. But the
aggregate should look like:
max_rain(rain, day) and return the day corresponding to the maximum
rain, So the query would be something like:
select max(rain), max_rain(rain, day) from meteo group by
date_part('year', day) where station=47654765;
I've tried to define a composite type for rain and day and the neccesary
functions to make the aggregate, but I cannot find the correct way. Can
someone help me? Is this sollution possible?
--
Salvador Maine
http://www.ronincoders.com
From | Date | Subject | |
---|---|---|---|
Next Message | Karel Zak | 2001-03-08 09:51:03 | Re: No Documentation for to_char(INTERVAL, mask) |
Previous Message | chard | 2001-03-08 08:46:46 | help |