5 Replies Latest reply on Dec 13, 2018 8:24 AM by xando

    Average SQL query

    xando

      Hi!

       

      I running this query and I like to collect average values between this two dates but this signals don't
      have values inside that range, it returns values that's over 1 year before the start date, it should then
      return 0 or null. What am I'm doing wrong?

       

      SELECT tag, CAST(value AS Float32) value, time
      FROM piarchive..piavg
      WHERE time BETWEEN DATE('2018-11-26 06:00:00') AND DATE('2018-12-03 06:00:00')
      AND tag IN ('PEX163_SAMPLES_01_CONS',
      'PEX163_SAMPLES_01_CSF',
      'PEX163_SAMPLES_01_s17',
      'PEX163_SAMPLES_01_s18',
      'PEX163_SAMPLES_01_WWFL',
      'PEX163_SAMPLES_01_f157',
      'PEX163_SAMPLES_01_TENI',
      'PEX163_SAMPLES_01_TEARI',
      'PEX163_SAMPLES_01_LSC_S',
      'PEX163_SAMPLES_01_x1',
      'PEX163_SAMPLES_01_LSC_BR'
      )

      /Anders