Re: Update Current Row Based on Prior Row

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philip Brooks <philswatch(at)yahoo(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Update Current Row Based on Prior Row
Date: 2012-06-02 21:17:11
Message-ID: 23694.1338671831@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Philip Brooks <philswatch(at)yahoo(dot)com> writes:
> In SQLite, I did it with this:
> UPDATE bf
> SET title = (
> SELECT title
> FROM bf AS prev
> WHERE title IS NOT NULL AND prev.rowid < bf.rowid
> ORDER BY prev.rowid DESC
> LIMIT 1
> )
> WHERE title IS NULL

> The update is not porting to Postgresql.

Really? Seems to work for me.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas Kretschmer 2012-06-03 07:37:57 Re: Update Current Row Based on Prior Row
Previous Message Philip Brooks 2012-06-02 16:43:43 Update Current Row Based on Prior Row