From: | Kirk Wythers <kwythers(at)umn(dot)edu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | problem with a conditional statement |
Date: | 2007-05-07 19:55:18 |
Message-ID: | 40942104-CA83-461B-BCF4-E511B7C6D3D8@umn.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am struggling to get a CASE WHEN statement to work within another
CASE WHEN. Here is my original code:
SELECT CASE WHEN w.station_id = site_near.station_id THEN w.obs_id ELSE
s.obs_id END AS obs_id, site_near.station_id, site_near.longname,
w.year, w.doy, w.precip, w.tmin, w.tmax,
--replace missing solar values (-999) with the average of all solar
values from that month (s.month)
--CASE s.par WHEN -999 THEN AVG( s.par) ELSE s.par END
--FROM solar s
--GROUP BY s.month;
FROM site_near INNER JOIN solar s ON
site_near.ref_solar_station_id = s.station_id AND site_near.obs_year
= s.year
INNER JOIN weather w ON site_near.ref_weather_station_id =
w.station_id AND site_near.obs_year = w.year AND s.date = w.date
WHERE w.station_id = 211630;
I have commented out the troublesome bits in the middle of the code.
All I am trying to do here is to replace missing values with averages
from the same day of the year for all years. Does anyone see what I
am buggering up here?
Thanks in advance
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2007-05-07 20:10:15 | Re: Date Math |
Previous Message | Richard Broersma Jr | 2007-05-07 19:51:58 | Win32 upgrade from 8.2.3 -> 8.2.4: What about the Documentation? |