PostgreSQL
 sql >> Datenbank >  >> RDS >> PostgreSQL

Minimale Variabilitätsprüfung in R oder PostgreSQL

   WITH A as (
   SELECT ambtemp,
          date_trunc('hour', dt)+
          CASE WHEN date_part('minute', dt) >= 6
          THEN interval '6 minutes'
          ELSE interval '0 minutes'
            END as t
          FROM temm),

              B as(
                  SELECT ambtemp,t,

   max(ambtemp::float(23)) OVER (PARTITION BY t) as max_temp,
   min(ambtemp::float(23)) OVER (PARTITION BY t) as min_temp
        FROM A)

          SELECT *

              FROM B
              WHERE (max_temp - min_temp) <= 0.5