Skip site navigation (1) Skip section navigation (2)

Re: DATA TYPE CONVERTION

From: Lennin Caro <lennin(dot)caro(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Subject: Re: DATA TYPE CONVERTION
Date: 2009-05-06 14:34:58
Message-ID: 734374.12678.qm@web59504.mail.ac4.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
use a cast type


create table test(
	id numeric
);

insert into test values(1);

insert into test values(2);

select id from test;

 id(numeric)
----
  1
  2
(2 rows)

select id::varchar from test;
or
select cast(id as varchar) from test

 id(varchar)
----
  1
  2
(2 rows)

--- On Mon, 5/4/09, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> wrote:

> From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
> Subject: [NOVICE] DATA TYPE CONVERTION
> To: pgsql-novice(at)postgresql(dot)org
> Date: Monday, May 4, 2009, 10:21 PM
> Is it possible to convert a numeric value to string within a
> SELECT query
> statement?
> For example, let's say that I have a table with a
> numeric field named
> "quantity". A normal SELECT would be "SELECT
> quantity FROM tblOrders". What
> if I want the value returned by the SELECT clause to be of
> type string
> instead of decimal?
> 
> Regards,
> Jorge Maldonado


      

In response to

pgsql-novice by date

Next:From: Pallayya Sarma KarraDate: 2009-05-08 16:02:28
Subject: attributes of columns from a table in postgresql database
Previous:From: Just E. MailDate: 2009-05-06 01:46:36
Subject: Replication

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group