Re: Merging 2 rows in a table

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Merging 2 rows in a table
Дата
Msg-id ift5t1$of7$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Merging 2 rows in a table  (Alexander Farber <alexander.farber@gmail.com>)
Ответы Re: Merging 2 rows in a table
Список pgsql-general
On 2011-01-03, Alexander Farber <alexander.farber@gmail.com> wrote:
> Hello,
>
> through some obscure error (probably on my side)

>  Column |         Type          |                Modifiers
> --------+-----------------------+-----------------------------------------
>  id     | character varying(32) |
>  money  | integer               | not null
>  yw     | character(7)          | default to_char(now(), 'YYYY-IW'::text)

'YYYY-IW' above should be 'IYYY-IW'

(you may have made a similar mistake in other places too.)

> I have several thousand entries for Jan 1 and Jan 2
> ending up in the ISO week 2011-52 instead of 2010-52
> which breaks the bar chart at the top of my script
> http://preferans.de/user.php?id=OK504891003571

> I would like to fix that problem by adding
> 2011-52 values of money (10 above) to the
> 2010-52 values of money (63 above, should become 73)
> and then dropping all rows with the
> wrong week number yw='2011-52'.

perhaps something like this:

 update pref_money as dat set money=dast.money+ foo.money from
  pref_money as foo where dat.id=foo.id
  and dat.yw='2011-52'
  and foo.yw ='2012-52' ;

--
⚂⚃ 100% natural

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

Предыдущее
От: Stefan Keller
Дата:
Сообщение: Re: Need advise for database structure for non linear data.
Следующее
От: Alexander Farber
Дата:
Сообщение: Re: Merging 2 rows in a table