Rounding result of expression in SELECT ..AS..

From: Michael Rowan <mike(dot)rowan(at)internode(dot)on(dot)net>
To: pgsql-novice novice <pgsql-novice(at)postgresql(dot)org>
Subject: Rounding result of expression in SELECT ..AS..
Date: 2011-12-15 13:36:54
Message-ID: C3C0596E-4466-4BB8-9A3F-7FE6DD543DF9@internode.on.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have three columns in my table:
netcost integer(9,2)
taxsum integer(9,2)
quantity integer

In my SELECT I have:

SELECT (netcost+taxsum)*quantity AS totalcost FROM etc etc

My problem is that the value in totalcost is, like, 49.500000000000

SELECT round((netcost+taxsum)*quantity, 2) AS totalcost FROM etc etc

gives the same result. What I want is 2DP, ie 49.50 in this example. Is there a way to achieve this?

TIA and for past help.

Michael Rowan
mike(dot)rowan(at)internode(dot)on(dot)net

11 Kingscote Street
ALBERTON
South Australia 5014

tel 618 8240 3993

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jayadevan M 2011-12-15 13:45:04 Re: Rounding result of expression in SELECT ..AS..
Previous Message Pushpendra Singh Thakur 2011-12-15 12:00:33 Re: Help with installing pgAdmin 3