query =
      Ecto.Query.from(dp in ztruct)
      |> Ecto.Query.select(
        [dp],
        [fragment(
          "date_trunc('day', ?)  + date_part('minute', ?)::int / 15 * interval '15 min' as hour",
          dp.read_on,
          dp.read_on
        ),
        fragment("max(?) - min(?)", dp.value, dp.value)]
      )
      |> Ecto.Query.where([dp], dp.read_on >= ^oldest)
      |> Ecto.Query.group_by([dp], fragment("hour"))
      |> Ecto.Query.order_by([dp], fragment("hour"))