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

Re: simple SQL question

From: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>
To: "'manchicken'" <manchicken(at)notsosoft(dot)net>,<pgsql-sql(at)postgresql(dot)org>
Subject: Re: simple SQL question
Date: 2007-06-25 15:19:49
Message-ID: 04c701c7b73c$46595990$8f01010a@iptel.com.ar (view raw or flat)
Thread:
Lists: pgsql-sql
> > I have a column with the following values (example below)
> >
> > 5673
> > 4731
> > 4462
> > 5422
> > 756
> > 3060
> >
> > I want the column to display the numbers as follows:
> >
> > 56.73
> > 47.31
> > 44.62
> > 54.22
> > 7.56
> > 30.60
> >
> > I have been playing around with string functions but cannot seem to
> > figure out a quick solution. Does anyone have any suggestions?
>
> Don't use to_char unless you actually want character data though.
> 
> Just try this...
> 
> SELECT (column/100) FROM table;

Cast the column in order to get the decimal part:

SELECT (column::real/100) FROM table;




In response to

Responses

pgsql-sql by date

Next:From: JoshuaDate: 2007-06-25 15:28:40
Subject: another simple SQL question
Previous:From: manchickenDate: 2007-06-25 15:05:29
Subject: Re: simple SQL question

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