Subtracting the mean of a field from derivative of another field


I have some data that I would like to calculate the derivative of, and then minus the mean of another field from this value and plot it. Here was my first thought

SELECT derivative("foo", 1s) - mean("bar") from measurement group by time(1s)

Alas, this gives me

InfluxDB Error: aggregate function required inside the call to derivative

Which isn’t particularly helpful since I have supplied that aggregate function.

Any ideas of how I can achieve what I want