4 Replies Latest reply on Nov 19, 2018 3:34 AM by Eugene Lee

    Crude oil statistic by query

    igreguri

      I made a query that extracts crudes (names) for a specific time period. Daily quantities are in some second PI point.

      How to calculate in the same query total sum, min, average and max for each crude, in period when it was processed?

      Ending time for processing one crude is the start of processing another crude.

       

      SELECT
      format (time,'dd.MM.yyyy hh:mm') as StartTime,
      CAST(value as string) as Crude
      FROM piarchive..picomp2
      WHERE Tag Like 'Crude.PV' and value is not null
      ORDER by time DESC

       

      Regards,

      Igor