Difference between revisions of "Growing Degree Day"

From HiveTool
Jump to: navigation, search
(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`,...")
 
Line 1: Line 1:
 
+
Calculate [http://en.wikipedia.org/wiki/Growing_degree_day Growing Degree Day (GDD)] for each hive and add to database.
  
 
  SET @gdd_total:=0;
 
  SET @gdd_total:=0;

Revision as of 18:54, 29 April 2018

Calculate Growing Degree Day (GDD) for each hive and add to database.

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