Re: How I can get the real data type result instead of integer data type?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Wei Wei <wei725(at)lycos(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How I can get the real data type result instead of integer data type?
Date: 2006-03-20 22:45:19
Message-ID: 20060320224519.GA7291@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 20, 2006 at 13:10:51 -0800,
Wei Wei <wei725(at)lycos(dot)com> wrote:
> In a query, there is something like
>
> order by count(id)/age
>
> where both id and age are the integer data type.
>
> From a query result, I believe the operation count(id)/age yields a integer. I need it in real data type. After searching the online document, I haven't found any related information. Can someone help me out on this problem, please.

You can cast the expressions. Something like:
order by count(id)::float/age::float

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vivek Khera 2006-03-20 22:53:25 Re: What's a good default encoding?
Previous Message Tom Lane 2006-03-20 22:31:32 Re: Difference between "add column" and "add column" with default