SELECT *, (TSTARTI+TSTARTF) AS ObsStart, (TSTOPI +TSTOPF) AS ObsEnd, (TSTOPI+TSTOPF-TSTARTI-TSTARTF)*24*3600 AS ObsTime, (TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600 AS EffTime, NTRGMISC/(TSTOPI+TSTOPF-TSTARTI-TSTARTF)/24/3600/Efficiency AS TrgRate, (RateCh0+RateCh1+RateCh2+RateCh3+RateCh4+RateCh5+RateCh6)/7 AS PatchRate, (RateSum0+RateSum1)/2 AS BoardRate, IF(TavgFTM>2048, TavgFTM-4096, TavgFTM) AS Tftm, Cnt500 /((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH500, Cnt750 /((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH750, Cnt1000/((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH1000, Cnt1250/((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH1250, Cnt1500/((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH1500, Cnt2000/((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH2000, Cnt5000/((TSTOPI+TSTOPF-TSTARTI-TSTARTF)*Efficiency*24*3600) AS TH5000 FROM RawData LEFT JOIN AuxData USING (Telescope, NIGHT, RUNID) LEFT JOIN SoftwareTrigger USING (Telescope, NIGHT, RUNID) LEFT JOIN DoNotUse USING (Telescope, NIGHT, RUNID) HAVING ObsTime>0 ORDER BY Telescope, NIGHT, RUNID