Get the max value from a slice of a JSON Array?
You can unnest json array:

Postgres WITH ORDINALITY:


  When a function in the FROM clause is suffixed by WITH ORDINALITY, a bigint column is appended to the output which starts from 1 and increments by 1 for each row of the function's output. This is most useful in the case of set returning functions such as unnest().


Have a look at this answer of Erwin Brandstetter:


PostgreSQL unnest() with element number




  SELECT
     r."ID",
     MAX(t.elem::int) MaxElem
  FROM   
      raw r
  JOIN
      features f
      ON f."ID" = r."ID"
  JOIN LATERAL
      json_array_elements_text(r."Data")
      WITH ORDINALITY AS t(elem, n) ON TRUE
  WHERE
      n &gt;= (f."Features"-&gt;&gt;'Start')::int + 1 
      AND 
      n &lt;= (f."Features"-&gt;&gt;'End')::int + 1
  GROUP BY
      r."ID";




ID | maxelem
-: | ------:
 1 |       7



db&lt;>fiddle here

Or if you prefer to use intarray module:

SELECT
    r."ID",
    (sort_desc(((ARRAY(SELECT json_array_elements_text(r."Data")))::int[])[(f."Features"-&gt;&gt;'Start')::int + 1:(f."Features"-&gt;&gt;'End')::int + 1]))[1]
FROM
    raw r
JOIN
    features f
    ON f."ID" = r."ID";


rextester here