Re: Join three fields into one on same table

Поиск
Список
Период
Сортировка
От Gurjeet Singh
Тема Re: Join three fields into one on same table
Дата
Msg-id 65937bea0805191748h4b11cedbr46b839117febec7c@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Join three fields into one on same table  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
On Tue, May 20, 2008 at 5:34 AM, Sam Mason <sam@samason.me.uk> wrote:
On Mon, May 19, 2008 at 03:36:39PM -0600, Scott Marlowe wrote:
> On Mon, May 19, 2008 at 4:51 AM, jrivero <godsea@gmail.com> wrote:
> > My problem is not that make update query.
> >
> >> update table set date=(select year || '-' || month || '-' || day || ' 01:00:00' as newdate from table)
>
> Cast the output of those concatenations to date:
>
> update table set date=(select (year || '-' || month || '-' || day || '
> 01:00:00')::date as newdate from table)

I'd guess the OP doesn't want the sub-query, if he posted the error
message we'd know for sure.  I'd guess something like:

 update table set date=(year||'-'||month||'-'||day||'01:00:00')::date;

That'd be my guess too. OP's subquery is possibly returning more than one row, and hence an error.



If the "date" column really is of date type, then the final
"||'01:00:00'" is somewhat superfluous.


--
gurjeet[.singh]@EnterpriseDB.com
singh.gurjeet@{ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

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

Предыдущее
От: "Dan Joo"
Дата:
Сообщение: psql: FATAL: Ident authentication failed for user "postgres"
Следующее
От: "Gregory Williamson"
Дата:
Сообщение: Re: Vacuuming on heavily changed databases