I am using PostgreSQL version 8.1. I have a table as follows:
datetime | usage
-----------------------+----------
2015-12-16 02:01:45+00 | 71.615
2015-12-16 03:14:42+00 | 43.000
2015-12-16 01:51:43+00 | 25.111
2015-12-17 02:05:26+00 | 94.087
I would like to add the integer values in the usage column based on the date in the datetime column.
Simply, I would like the output to look as below:
datetime | usage
-----------------------+----------
2015-12-16 | 139.726
2015-12-17 | 94.087
I have tried SELECT dateTime::DATE, usage, SUM(usage) FROM tableName GROUP BY dateTime::DATE, lngusage; which does not perform as expected. Any assistance would be appreciated. Thanks in advance.
DATE_TRUNC('day', datetime)according to the docs