Failed to get SUM over time period

I am not an expert of InfluxDB but up to now I was able to get what I want.
Now I am stuck :frowning:

We monitor the level of our water tank with an ultrasonic sensor. The following diagram shows the water consumption and the refill as an 24h example. The according query is:

SELECT min("value") AS "min_value" FROM "homeassistant"."autogen"."l" WHERE time > :dashboardTime: AND time < :upperDashboardTime: AND "entity_id"='water_tank_volume_2' GROUP BY time(1m) FILL(null)

In order to calculate the water consumption I used the transformation NON_NEGATIVE_DIFFERENCE in the query statement:

SELECT NON_NEGATIVE_DIFFERENCE("min_value") as "delta" FROM (SELECT -min("value") AS "min_value" FROM "homeassistant"."autogen"."l" WHERE time > :dashboardTime: AND time < :upperDashboardTime: AND "entity_id"='water_tank_volume_2' GROUP BY time(1m) FILL(null))

The result looks as expected.

If I like to summarise now the water consumption over a given time period (for instance per day) I only can get the total sum of the entire period and GROUP BY time(1d) doesnโ€™t work:

SELECT sum("delta") as "used" FROM (SELECT NON_NEGATIVE_DIFFERENCE("min_value") as "delta" FROM (SELECT -min("value") AS "min_value" FROM "homeassistant"."autogen"."l" WHERE time > :dashboardTime: AND time < :upperDashboardTime: AND "entity_id"='water_tank_volume_2' GROUP BY time(1m) FILL(null))) 

Where is my mistake ?

Here the consumption data over time (output of second query):