Re: Changing Data Types

From: James David Smith <james(dot)david(dot)smith(at)gmail(dot)com>
To: Mike Frost <m_frost2010(at)hotmail(dot)com>, Thom Brown <thom(at)linux(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Changing Data Types
Date: 2015-09-07 10:35:16
Message-ID: CAMu32AAhFt0kbV+7-WynFq5jZ-h9f1xOiz4m6D1A72GjZNsiMw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

More like column::datatype , but you get the idea yes.

On Mon, 7 Sep 2015 at 11:34 Mike Frost <m_frost2010(at)hotmail(dot)com> wrote:

> thanks man!
>
> so the syntax in [fielname]::[datatype]?
> ------------------------------
> From: thom(at)linux(dot)com
> Date: Mon, 7 Sep 2015 11:27:46 +0100
> Subject: Re: [NOVICE] Changing Data Types
> To: m_frost2010(at)hotmail(dot)com
> CC: tgl(at)sss(dot)pgh(dot)pa(dot)us; pgsql-novice(at)postgresql(dot)org
>
>
> On 7 September 2015 at 11:20, Mike Frost <m_frost2010(at)hotmail(dot)com> wrote:
>
> Hi All,
>
> This REALLY is a novice question
>
> I'm writing a simple query where i need to return [Field A]/[Field B] so
> i can express [Field A] as a percentage
>
> Both of these fields are BigInts, so i always get 0
>
> What do i need to do to the data types in my query to enable decimal
> places?
>
>
> You can cast at least one of them to numeric:
>
> postgres=# SELECT 7::int / 10::int;
> ?column?
> ----------
> 0
> (1 row)
>
> postgres=# SELECT 7::numeric / 10::int;
> ?column?
> ------------------------
> 0.70000000000000000000
> (1 row)
>
> Thom
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Thom Brown 2015-09-07 10:38:59 Re: Changing Data Types
Previous Message Mike Frost 2015-09-07 10:33:30 Re: Changing Data Types