Arithmetic inside aggregate function, and min/max(a,b) function

Hi all,

I am new to influxDB and the query language, and I could use help simplifying a query. I have two fields “east” and “pv”, and I am trying to calculate the SUM aggregate of this expression:

MIN("east", 0) - "pv"

I couldn’t find a min/max function, and I can’t seem to be able to use arithmetic inside the sum aggregate function, so the best I could come up with is:

select sum(pv1) as pv FROM (
    SELECT "east" - abs("east"))/2 - "pv" as pv1 
    FROM "energy" WHERE  $timeFilter) 
WHERE  $timeFilter GROUP BY time($kWh_interval,-1h) fill(null)```

Did I miss an easier approach?
Thanks for your help!