I have constructed a naive query that works for my application, which returns multiple values from a table that contains an array of reals.
SELECT
"timestamp" AS "time",
type as metric,
id,
values[80],
values[81],
values[82],
values[83],
values[84],
values[85],
values[86],
values[87],
values[88],
values[89],
values[91],
values[92],
values[93],
values[94],
values[95],
values[96],
values[97],
values[98],
values[99],
values[100],
values[101]
FROM test_table
WHERE
"timestamp" BETWEEN '2021-04-03T15:05:56.928Z' AND '2021-04-03T15:10:56.928Z'
ORDER BY 1
However, for obvious reasons, I want to avoid long lists of values[n] in my query, especially as in fact I need to get up to 1000 values.
I know that it is possible to iterate over an array but everything I try to replace the list of array subscripts along the lines of
FOR i IN ARRAY values
LOOP
values [i]
END LOOP;
errors out.
As an obvious SQL noob, can someone suggest how this might query might be done more elegantly?