Re: type conversion?

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: type conversion?
Дата
Msg-id 20020409104600.H95735-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на type conversion?  (Peter Atkins <Peter.Atkins@nextcard.com>)
Список pgsql-sql
On Tue, 9 Apr 2002, Peter Atkins wrote:

> I have a column "total_hours  |  character varying(5) " and I am unable to
> perform the aggrigate function SUM() because of the column type.
> Without changing the type is there a way to convert the datatype by using
> CAST(), to_char() or something simular? So that I may calculate the SUM().
>
> SELECT SUM(total_hours) AS hours FROM my_table WHERE flag='$flag';

I think this may work:
SELECT SUM(to_number(total_hours, '99999')) from my_table where ...



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

Предыдущее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: type conversion?
Следующее
От: Michael Teter
Дата:
Сообщение: Yes! Thank you!