NCRN / ForestVeg

Front end application for NCRN Forest Vegetation Access database.
3 stars 1 forks source link

[BUG] Veg exports incorrectly calculate the `Cycle` #229

Open cwainright opened 3 months ago

cwainright commented 3 months ago

Problems present in:

Each of these queries calculates Cycle as 1+Int((Year([Event_Date])-2006)/4). Since Covid wrecked 2020, the result returned by that calculation is off by one for each year after 2019 and will be off in perpetuity unless the queries are fixed.

possible solution:

-- building block
-- this is how you join table `PanelSeason` to `tbl_Events`
-- this code chunk is re-used in each of the queries above (basically, in each instance of `tbl_Events as E`)

SELECT 
*
FROM 
  ((
    SELECT 
      Event_ID, 
      Str(Year([Event_Date])) AS str_year 
    FROM 
      tbl_Events
  )  AS tbl_E
  INNER JOIN (
    SELECT 
      Cycle, 
      Str(PanelSeason.FieldSeason) as str_season 
    FROM 
      PanelSeason
  ) AS tbl_P
ON 
  tbl_P.str_season = tbl_E.str_year)
;
cwainright commented 3 months ago

references ticket 115

cwainright commented 3 months ago

All queries drafted to use lookup table PanelSeason instead of calculating Cycle. Unit testing now.

cwainright commented 2 months ago

"l_Unit_Code" should be "Unit_Code" and "usys_temp_qdf_Unit_Code"s should be deleted