Wrong calculation on sum

I am trying to display the total energy usage from devices in grafana backed by influxdb however the value for the sum is wrong. Here are the two queries for example.

SELECT sum("value") FROM (SELECT last("value") - first("value") AS "value" FROM "kWh" WHERE $timeFilter GROUP BY "entity_id") WHERE $timeFilter

SELECT last("value") - first("value") AS "value" FROM "kWh" WHERE $timeFilter GROUP BY "entity_id"

As you can see it’s showing 0.99 as the sum when It should be 1.7.

Update and now again with influxdb CLI

> SELECT last("value") - first("value") AS "value" FROM "kWh" WHERE time > now() - 24h  GROUP BY "entity_id"
name: kWh
tags: entity_id=socketcoffee_energy
time                value
----                -----
1537863368390823721 0.41900000000000004

name: kWh
tags: entity_id=socketdesk_energy
time                value
----                -----
1537863368390823721 0.17999999999999994

name: kWh
tags: entity_id=socketmedia_energy
time                value
----                -----
1537863368390823721 0.4980000000000002

name: kWh
tags: entity_id=sockettable_energy
time                value
----                -----
1537863368390823721 0.049999999999999996

And SUM

> SELECT sum("value") FROM (SELECT last("value") - first("value") AS "value" FROM "kWh" WHERE time > now() - 24h  GROUP BY "entity_id") 
name: kWh
time sum
---- ---
0    0.5480000000000003