Обсуждение: simple SQL question

Поиск
Список
Период
Сортировка

simple SQL question

От
Joshua
Дата:
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?

Please let me know.

Thanks.


Re: {Spam} simple SQL question

От
Dimitri Fontaine
Дата:
Le lundi 25 juin 2007, Joshua a écrit :
> I have been playing around with string functions but cannot seem to
> figure out a quick solution. Does anyone have any suggestions?
>
> Please let me know.

What about:

pgloader=# select a::float / 100 from (values(5673), (4731), (4462), (5422),
(756), (3060)) as x(a);
 ?column?
----------
    56.73
    47.31
    44.62
    54.22
     7.56
     30.6
(6 lignes)

--
dim

Вложения

Re: simple SQL question

От
Rich Shepard
Дата:
On Mon, 25 Jun 2007, Joshua wrote:

> I have a column with the following values (example below)
>
> 5673
> 4731
> 4462
> 5422
> 756
> 3060

   Are these numbers that will be used in calculations, or are they strings?

> I want the column to display the numbers as follows:
>
> 56.73
> 47.31
> 44.62
> 54.22
> 7.56
> 30.60

   Numeric(4,2) will do this. Also, whatever the UI you are using in your
application can make the translation from display format to storage format.

> I have been playing around with string functions but cannot seem to figure
> out a quick solution. Does anyone have any suggestions?

   If they are strings, why not enter and store them with the decimal point?

Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.        |          Accelerator(TM)
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863