Search Postgresql Archives

Re: Merging 2 rows in a table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2011-01-03, Alexander Farber <alexander.farber@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux