Re: Merging 2 rows in a table - Mailing list pgsql-general

From Jasen Betts
Subject Re: Merging 2 rows in a table
Date
Msg-id ift5t1$of7$1@reversiblemaps.ath.cx
Whole thread Raw
In response to Merging 2 rows in a table  (Alexander Farber <alexander.farber@gmail.com>)
Responses Re: Merging 2 rows in a table  (Alexander Farber <alexander.farber@gmail.com>)
List 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 by date:

Previous
From: Stefan Keller
Date:
Subject: Re: Need advise for database structure for non linear data.
Next
From: Alexander Farber
Date:
Subject: Re: Merging 2 rows in a table