Calculate series from POSTGRES

I have a table in POSTGRES with the following structure


in addition to feature 185 and 179 there is 32 other features in the datatable. Currently approximately 9 mill. rows and new inflow of rows approximately 1 mill. rows per month.

I am using Grafana to visualise features 185 and 178 by during the following Select

Series A
SELECT __time(timestamp/1000,10m,previous), avg(engineeringvalue) AS "Feature A" FROM analogsignalfud WHERE id=178 and timestamp &gt;= __unixEpochFrom()::bigint1000 and timestamp <= $__unixEpochTo()::bigint1000 GROUP BY 1 ORDER BY 1

Series B
SELECT __time(timestamp/1000,10m,previous), avg(engineeringvalue) AS "Available Power" FROM analogsignalfud WHERE id=185 and timestamp &gt;= __unixEpochFrom()::bigint1000 and timestamp <= $__unixEpochTo()::bigint1000 GROUP BY 1 ORDER BY 1

This is working very well to graph the features. The features are derived from an event based log and therefore the “timestamp” are not synchronised between that features. Still Grafana “fix” this in the Graph where the data is visualised.

I want to use the A and B Series in a new Series C that is a calculated features where A and B are used. Is this possible when Postgres is the source and the timestamp for the Features are not synchronised.