Growing Degree Day

From HiveTool
Revision as of 18:53, 29 April 2018 by Paul (talk | contribs) (Created page with " SET @gdd_total:=0; SELECT q1.doy, q1.gdd, round(@gdd_total := @gdd_total + q1.gdd) as gdd_tot FROM (SELECT DAYOFYEAR(DATE_FORMAT(`hive_observation_time_local`,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


SET @gdd_total:=0;
SELECT
  q1.doy,
  q1.gdd,
  round(@gdd_total := @gdd_total + q1.gdd) as gdd_tot
FROM
 (SELECT DAYOFYEAR(DATE_FORMAT(`hive_observation_time_local`, '%Y-%m-%d')) AS doy,
  (least(greatest(max(wx_temp_c),10),30) - least(greatest(min(wx_temp_c),10),30))/2 AS gdd
  from HIVE_DATA 
  where hive_id=10 group by DATE_FORMAT(`hive_observation_time_local`, '%Y-%m-%d') ) AS q1



SELECT hive_id, DAYOFYEAR(DATE_FORMAT(`hive_observation_time_local`, '%Y-%m-%d')) AS doy,
  (least(greatest(max(wx_temp_c),10),30) - least(greatest(min(wx_temp_c),10),30))/2 AS gdd
  from HIVE_DATA group by DATE_FORMAT(`hive_observation_time_local`, '%Y-%m-%d'), hive_id