On 10/09/2013, James David Smith <james.david.smith@gmail.com> wrote:
> Hey there,
>
> Is this what you are after? Note that I've changed the 'money' type to
> numeric.
>
Why did you change the data type? Answered my own question by changing
the data type to numeric as you did:
date_part | ?column?
-----------+----------
1 | £-730
2 | £60
(2 rows)
The position of the negative sign (-) is wrong; presumably this a
consequence of the 'numeric' data type that cannot be changed?
The extract function:
>
> SELECT EXTRACT(month FROM(date)), SUM(amount) FROM testgroupsum GROUP
> BY EXTRACT(month FROM(date));
>
returns:
date_part | sum
-----------+----------
1 | -$365.00
2 | $30.00
(2 rows)
> -- Then if you want to put an dollar or whatever you could do this:
>
> SELECT EXTRACT(month FROM(date)), '£' || SUM(amount) FROM testgroupsum
> GROUP BY EXTRACT(month FROM(date));
>
returns:
date_part | ?column?
-----------+------------
1 | £-$365.00
2 | £$30.00
(2 rows)