SQLSTATE[42S22]: Column not found: 1054 Unknown column 'maxt' in 'field list' with query: SELECT id as station, maxt, ob, DATE_FORMAT('2023-08-01 00:00:00', '%W, %M %D, %Y') as startfulldate, DATE_FORMAT(ob, '%W, %M %D, %Y') as endfulldate, DATE_FORMAT('2023-08-01 00:00:00', '%b %D') as startmd, DATE_FORMAT(ob, '%b %D') as endmd, YEAR(ob) as year, IF(DATE_FORMAT('2023-08-01 00:00:00', '%Y') = DATE_FORMAT(ob, '%Y'), DATE_FORMAT('2023-08-21 23:59:59', '%Y'), CONCAT(DATE_FORMAT('2023-08-01 00:00:00', '%Y'),'-',DATE_FORMAT(ob, '%Y'))) as years,1+(DATEDIFF(ob,'2023-08-01 00:00:00')) as diff,1 as obsperday, IF(DATE_FORMAT('2023-08-01 00:00:00', '%Y-%m-%d') = DATE_FORMAT(ob, '%Y-%m-%d'), DATE_FORMAT(ob, '%b. %D, %Y'), CONCAT(DATE_FORMAT('2023-08-01 00:00:00', '%m/%d/%y'),' - ',DATE_FORMAT(ob, '%m/%d/%y'))) as daterange,1 as num_obs, numobs, gen23p33, sdatemaxgen23p33, edatemaxgen23p33, maxgen23p33, totalgen23p33,gen17p78, sdatemaxgen17p78, edatemaxgen17p78, maxgen17p78, totalgen17p78,gen12p22, sdatemaxgen12p22, edatemaxgen12p22, maxgen12p22, totalgen12p22,gen6p67, sdatemaxgen6p67, edatemaxgen6p67, maxgen6p67, totalgen6p67,gen1p12, sdatemaxgen1p12, edatemaxgen1p12, maxgen1p12, totalgen1p12,gt0, sdatemaxgt0, edatemaxgt0, maxgt0, totalgt0,le0, sdatemaxle0, edatemaxle0, maxle0, totalle0,ge4p44, sdatemaxge4p44, edatemaxge4p44, maxge4p44, totalge4p44,ge10, sdatemaxge10, edatemaxge10, maxge10, totalge10,ge15p56, sdatemaxge15p56, edatemaxge15p56, maxge15p56, totalge15p56,ge21p11, sdatemaxge21p11, edatemaxge21p11, maxge21p11, totalge21p11,ge26p67, sdatemaxge26p67, edatemaxge26p67, maxge26p67, totalge26p67,ge29p44, sdatemaxge29p44, edatemaxge29p44, maxge29p44, totalge29p44,ge32p22, sdatemaxge32p22, edatemaxge32p22, maxge32p22, totalge32p22,ge35, sdatemaxge35, edatemaxge35, maxge35, totalge35,ge37p78, sdatemaxge37p78, edatemaxge37p78, maxge37p78, totalge37p78,ge43p33, sdatemaxge43p33, edatemaxge43p33, maxge43p33, totalge43p33 FROM (SELECT *,@'totobs':=IF(ob,@'totobs'+1,@'totobs') as 'numobs',@'cgen23p33':=IF(ROUND(maxt,2)>=-23.33,@'cgen23p33'+1,0) as 'gen23p33',@'mgen23p33':=IF(@'cgen23p33'>=@'mgen23p33',@'cgen23p33',@'mgen23p33') as 'maxgen23p33',@'tgen23p33':=IF(@'cgen23p33'>0,@'tgen23p33'+1,@'tgen23p33') as 'totalgen23p33',@'sdgen23p33':=IF(@'cgen23p33'>=@'mgen23p33' AND @'cgen23p33'>0,CAST(DATE_SUB(ob, INTERVAL (@'cgen23p33' - 1) DAY) as DATE),@'sdgen23p33') as 'sdatemaxgen23p33',@'edgen23p33':=IF(@'cgen23p33'>=@'mgen23p33' AND @'cgen23p33'>0,CAST(ob as DATE),@'edgen23p33') as 'edatemaxgen23p33',@'cgen17p78':=IF(ROUND(maxt,2)>=-17.78,@'cgen17p78'+1,0) as 'gen17p78',@'mgen17p78':=IF(@'cgen17p78'>=@'mgen17p78',@'cgen17p78',@'mgen17p78') as 'maxgen17p78',@'tgen17p78':=IF(@'cgen17p78'>0,@'tgen17p78'+1,@'tgen17p78') as 'totalgen17p78',@'sdgen17p78':=IF(@'cgen17p78'>=@'mgen17p78' AND @'cgen17p78'>0,CAST(DATE_SUB(ob, INTERVAL (@'cgen17p78' - 1) DAY) as DATE),@'sdgen17p78') as 'sdatemaxgen17p78',@'edgen17p78':=IF(@'cgen17p78'>=@'mgen17p78' AND @'cgen17p78'>0,CAST(ob as DATE),@'edgen17p78') as 'edatemaxgen17p78',@'cgen12p22':=IF(ROUND(maxt,2)>=-12.22,@'cgen12p22'+1,0) as 'gen12p22',@'mgen12p22':=IF(@'cgen12p22'>=@'mgen12p22',@'cgen12p22',@'mgen12p22') as 'maxgen12p22',@'tgen12p22':=IF(@'cgen12p22'>0,@'tgen12p22'+1,@'tgen12p22') as 'totalgen12p22',@'sdgen12p22':=IF(@'cgen12p22'>=@'mgen12p22' AND @'cgen12p22'>0,CAST(DATE_SUB(ob, INTERVAL (@'cgen12p22' - 1) DAY) as DATE),@'sdgen12p22') as 'sdatemaxgen12p22',@'edgen12p22':=IF(@'cgen12p22'>=@'mgen12p22' AND @'cgen12p22'>0,CAST(ob as DATE),@'edgen12p22') as 'edatemaxgen12p22',@'cgen6p67':=IF(ROUND(maxt,2)>=-6.67,@'cgen6p67'+1,0) as 'gen6p67',@'mgen6p67':=IF(@'cgen6p67'>=@'mgen6p67',@'cgen6p67',@'mgen6p67') as 'maxgen6p67',@'tgen6p67':=IF(@'cgen6p67'>0,@'tgen6p67'+1,@'tgen6p67') as 'totalgen6p67',@'sdgen6p67':=IF(@'cgen6p67'>=@'mgen6p67' AND @'cgen6p67'>0,CAST(DATE_SUB(ob, INTERVAL (@'cgen6p67' - 1) DAY) as DATE),@'sdgen6p67') as 'sdatemaxgen6p67',@'edgen6p67':=IF(@'cgen6p67'>=@'mgen6p67' AND @'cgen6p67'>0,CAST(ob as DATE),@'edgen6p67') as 'edatemaxgen6p67',@'cgen1p12':=IF(ROUND(maxt,2)>=-1.12,@'cgen1p12'+1,0) as 'gen1p12',@'mgen1p12':=IF(@'cgen1p12'>=@'mgen1p12',@'cgen1p12',@'mgen1p12') as 'maxgen1p12',@'tgen1p12':=IF(@'cgen1p12'>0,@'tgen1p12'+1,@'tgen1p12') as 'totalgen1p12',@'sdgen1p12':=IF(@'cgen1p12'>=@'mgen1p12' AND @'cgen1p12'>0,CAST(DATE_SUB(ob, INTERVAL (@'cgen1p12' - 1) DAY) as DATE),@'sdgen1p12') as 'sdatemaxgen1p12',@'edgen1p12':=IF(@'cgen1p12'>=@'mgen1p12' AND @'cgen1p12'>0,CAST(ob as DATE),@'edgen1p12') as 'edatemaxgen1p12',@'cgt0':=IF(ROUND(maxt,2)>0,@'cgt0'+1,0) as 'gt0',@'mgt0':=IF(@'cgt0'>=@'mgt0',@'cgt0',@'mgt0') as 'maxgt0',@'tgt0':=IF(@'cgt0'>0,@'tgt0'+1,@'tgt0') as 'totalgt0',@'sdgt0':=IF(@'cgt0'>=@'mgt0' AND @'cgt0'>0,CAST(DATE_SUB(ob, INTERVAL (@'cgt0' - 1) DAY) as DATE),@'sdgt0') as 'sdatemaxgt0',@'edgt0':=IF(@'cgt0'>=@'mgt0' AND @'cgt0'>0,CAST(ob as DATE),@'edgt0') as 'edatemaxgt0',@'cle0':=IF(ROUND(maxt,2)<=0,@'cle0'+1,0) as 'le0',@'mle0':=IF(@'cle0'>=@'mle0',@'cle0',@'mle0') as 'maxle0',@'tle0':=IF(@'cle0'>0,@'tle0'+1,@'tle0') as 'totalle0',@'sdle0':=IF(@'cle0'>=@'mle0' AND @'cle0'>0,CAST(DATE_SUB(ob, INTERVAL (@'cle0' - 1) DAY) as DATE),@'sdle0') as 'sdatemaxle0',@'edle0':=IF(@'cle0'>=@'mle0' AND @'cle0'>0,CAST(ob as DATE),@'edle0') as 'edatemaxle0',@'cge4p44':=IF(ROUND(maxt,2)>=4.44,@'cge4p44'+1,0) as 'ge4p44',@'mge4p44':=IF(@'cge4p44'>=@'mge4p44',@'cge4p44',@'mge4p44') as 'maxge4p44',@'tge4p44':=IF(@'cge4p44'>0,@'tge4p44'+1,@'tge4p44') as 'totalge4p44',@'sdge4p44':=IF(@'cge4p44'>=@'mge4p44' AND @'cge4p44'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge4p44' - 1) DAY) as DATE),@'sdge4p44') as 'sdatemaxge4p44',@'edge4p44':=IF(@'cge4p44'>=@'mge4p44' AND @'cge4p44'>0,CAST(ob as DATE),@'edge4p44') as 'edatemaxge4p44',@'cge10':=IF(ROUND(maxt,2)>=10,@'cge10'+1,0) as 'ge10',@'mge10':=IF(@'cge10'>=@'mge10',@'cge10',@'mge10') as 'maxge10',@'tge10':=IF(@'cge10'>0,@'tge10'+1,@'tge10') as 'totalge10',@'sdge10':=IF(@'cge10'>=@'mge10' AND @'cge10'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge10' - 1) DAY) as DATE),@'sdge10') as 'sdatemaxge10',@'edge10':=IF(@'cge10'>=@'mge10' AND @'cge10'>0,CAST(ob as DATE),@'edge10') as 'edatemaxge10',@'cge15p56':=IF(ROUND(maxt,2)>=15.56,@'cge15p56'+1,0) as 'ge15p56',@'mge15p56':=IF(@'cge15p56'>=@'mge15p56',@'cge15p56',@'mge15p56') as 'maxge15p56',@'tge15p56':=IF(@'cge15p56'>0,@'tge15p56'+1,@'tge15p56') as 'totalge15p56',@'sdge15p56':=IF(@'cge15p56'>=@'mge15p56' AND @'cge15p56'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge15p56' - 1) DAY) as DATE),@'sdge15p56') as 'sdatemaxge15p56',@'edge15p56':=IF(@'cge15p56'>=@'mge15p56' AND @'cge15p56'>0,CAST(ob as DATE),@'edge15p56') as 'edatemaxge15p56',@'cge21p11':=IF(ROUND(maxt,2)>=21.11,@'cge21p11'+1,0) as 'ge21p11',@'mge21p11':=IF(@'cge21p11'>=@'mge21p11',@'cge21p11',@'mge21p11') as 'maxge21p11',@'tge21p11':=IF(@'cge21p11'>0,@'tge21p11'+1,@'tge21p11') as 'totalge21p11',@'sdge21p11':=IF(@'cge21p11'>=@'mge21p11' AND @'cge21p11'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge21p11' - 1) DAY) as DATE),@'sdge21p11') as 'sdatemaxge21p11',@'edge21p11':=IF(@'cge21p11'>=@'mge21p11' AND @'cge21p11'>0,CAST(ob as DATE),@'edge21p11') as 'edatemaxge21p11',@'cge26p67':=IF(ROUND(maxt,2)>=26.67,@'cge26p67'+1,0) as 'ge26p67',@'mge26p67':=IF(@'cge26p67'>=@'mge26p67',@'cge26p67',@'mge26p67') as 'maxge26p67',@'tge26p67':=IF(@'cge26p67'>0,@'tge26p67'+1,@'tge26p67') as 'totalge26p67',@'sdge26p67':=IF(@'cge26p67'>=@'mge26p67' AND @'cge26p67'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge26p67' - 1) DAY) as DATE),@'sdge26p67') as 'sdatemaxge26p67',@'edge26p67':=IF(@'cge26p67'>=@'mge26p67' AND @'cge26p67'>0,CAST(ob as DATE),@'edge26p67') as 'edatemaxge26p67',@'cge29p44':=IF(ROUND(maxt,2)>=29.44,@'cge29p44'+1,0) as 'ge29p44',@'mge29p44':=IF(@'cge29p44'>=@'mge29p44',@'cge29p44',@'mge29p44') as 'maxge29p44',@'tge29p44':=IF(@'cge29p44'>0,@'tge29p44'+1,@'tge29p44') as 'totalge29p44',@'sdge29p44':=IF(@'cge29p44'>=@'mge29p44' AND @'cge29p44'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge29p44' - 1) DAY) as DATE),@'sdge29p44') as 'sdatemaxge29p44',@'edge29p44':=IF(@'cge29p44'>=@'mge29p44' AND @'cge29p44'>0,CAST(ob as DATE),@'edge29p44') as 'edatemaxge29p44',@'cge32p22':=IF(ROUND(maxt,2)>=32.22,@'cge32p22'+1,0) as 'ge32p22',@'mge32p22':=IF(@'cge32p22'>=@'mge32p22',@'cge32p22',@'mge32p22') as 'maxge32p22',@'tge32p22':=IF(@'cge32p22'>0,@'tge32p22'+1,@'tge32p22') as 'totalge32p22',@'sdge32p22':=IF(@'cge32p22'>=@'mge32p22' AND @'cge32p22'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge32p22' - 1) DAY) as DATE),@'sdge32p22') as 'sdatemaxge32p22',@'edge32p22':=IF(@'cge32p22'>=@'mge32p22' AND @'cge32p22'>0,CAST(ob as DATE),@'edge32p22') as 'edatemaxge32p22',@'cge35':=IF(ROUND(maxt,2)>=35,@'cge35'+1,0) as 'ge35',@'mge35':=IF(@'cge35'>=@'mge35',@'cge35',@'mge35') as 'maxge35',@'tge35':=IF(@'cge35'>0,@'tge35'+1,@'tge35') as 'totalge35',@'sdge35':=IF(@'cge35'>=@'mge35' AND @'cge35'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge35' - 1) DAY) as DATE),@'sdge35') as 'sdatemaxge35',@'edge35':=IF(@'cge35'>=@'mge35' AND @'cge35'>0,CAST(ob as DATE),@'edge35') as 'edatemaxge35',@'cge37p78':=IF(ROUND(maxt,2)>=37.78,@'cge37p78'+1,0) as 'ge37p78',@'mge37p78':=IF(@'cge37p78'>=@'mge37p78',@'cge37p78',@'mge37p78') as 'maxge37p78',@'tge37p78':=IF(@'cge37p78'>0,@'tge37p78'+1,@'tge37p78') as 'totalge37p78',@'sdge37p78':=IF(@'cge37p78'>=@'mge37p78' AND @'cge37p78'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge37p78' - 1) DAY) as DATE),@'sdge37p78') as 'sdatemaxge37p78',@'edge37p78':=IF(@'cge37p78'>=@'mge37p78' AND @'cge37p78'>0,CAST(ob as DATE),@'edge37p78') as 'edatemaxge37p78',@'cge43p33':=IF(ROUND(maxt,2)>=43.33,@'cge43p33'+1,0) as 'ge43p33',@'mge43p33':=IF(@'cge43p33'>=@'mge43p33',@'cge43p33',@'mge43p33') as 'maxge43p33',@'tge43p33':=IF(@'cge43p33'>0,@'tge43p33'+1,@'tge43p33') as 'totalge43p33',@'sdge43p33':=IF(@'cge43p33'>=@'mge43p33' AND @'cge43p33'>0,CAST(DATE_SUB(ob, INTERVAL (@'cge43p33' - 1) DAY) as DATE),@'sdge43p33') as 'sdatemaxge43p33',@'edge43p33':=IF(@'cge43p33'>=@'mge43p33' AND @'cge43p33'>0,CAST(ob as DATE),@'edge43p33') as 'edatemaxge43p33' FROM tmp.CP_DATA1229334773 WHERE station = '317069' AND ob >= '2023-08-01 00:00:00' AND ob <= '2023-08-21 23:59:59') as temps HAVING DATE_FORMAT(ob,'%Y-%m-%d')=DATE_FORMAT('2023-08-21 23:59:59','%Y-%m-%d')

Error Trace: