Skip to content

Commit

Permalink
Allow one missing value for daily aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
clampr committed May 7, 2024
1 parent 60057d8 commit 92521f4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cron/export/bulk/stations/daily.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ UNION all (SELECT `date`,
FROM `daily_ghcn`
WHERE `station` = :station)
UNION all (SELECT date(`time`) as `date`,
if(count(`temp`) < 24, null, round(avg(`temp`), 1)) as `tavg`,
if(count(`temp`) < 24, null, min(`temp`)) as `tmin`,
if(count(`temp`) < 24, null, max(`temp`)) as `tmax`,
if(count(`prcp`) < 24, null, round(sum(`prcp`), 1)) as `prcp`,
if(count(`snow`) < 24, null, max(`snow`)) as `snow`,
if(count(`wdir`) < 24,
if(count(`temp`) < 23, null, round(avg(`temp`), 1)) as `tavg`,
if(count(`temp`) < 23, null, min(`temp`)) as `tmin`,
if(count(`temp`) < 23, null, max(`temp`)) as `tmax`,
if(count(`prcp`) < 23, null, round(sum(`prcp`), 1)) as `prcp`,
if(count(`snow`) < 23, null, max(`snow`)) as `snow`,
if(count(`wdir`) < 23,
null,
round(degavg(sum(sin(radians(`wdir`))), sum(cos(radians(`wdir`)))), 1)) as `wdir`,
if(count(`wspd`) < 24, null, round(avg(`wspd`), 1)) as `wspd`,
if(count(`wpgt`) < 24, null, max(`wpgt`)) as `wpgt`,
if(count(`pres`) < 24, null, round(avg(`pres`), 1)) as `pres`,
if(count(`wspd`) < 23, null, round(avg(`wspd`), 1)) as `wspd`,
if(count(`wpgt`) < 23, null, max(`wpgt`)) as `wpgt`,
if(count(`pres`) < 23, null, round(avg(`pres`), 1)) as `pres`,
null as `tsun`,
group_concat(distinct `temp_flag` separator '') as `tavg_flag`,
group_concat(distinct `temp_flag` separator '') as `tmin_flag`,
Expand Down

0 comments on commit 92521f4

Please sign in to comment.