Re: [SQL] Absolute value on int2 or int4 field

Поиск
Список
Период
Сортировка
От Guido Piazzi
Тема Re: [SQL] Absolute value on int2 or int4 field
Дата
Msg-id Pine.LNX.3.96.980828104441.130B-100000@ik2gdx.ampr.org
обсуждение исходный текст
Ответ на Absolute value on int2 or int4 field  (Chris Johnson <cmj@inline-design.com>)
Список pgsql-sql
On Thu, 27 Aug 1998, Chris Johnson wrote:

> I need to sort a list of entries by the absolute value of a particular
> field.  I examined the documentation and found that @ is the operator that
> I need, but it doesn't appear to work on int2 or int4 fields.
>
> Anyone have any ideas on how to accomplish this?

guido=> select @a::float as abs from test order by abs;
abs
---
  1
  2
(2 rows)

I run 6.3.1 on Linux 2.0.27.  BTW, trying to insert -2 into float
fields without casting didn't work on my box!

Regards, Guido
--------------------------------------------
Guido Carlo Piazzi           gpiazzi@nemo.it
Non coronabitur nisi qui legitime certaverit


В списке pgsql-sql по дате отправления:

Предыдущее
От: Walt Bigelow
Дата:
Сообщение: Re: [SQL] copy one to many?
Следующее
От: "Shawn T. Walker"
Дата:
Сообщение: Contertine timespan to hours