Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 7DD319FA1FE for ; Fri, 1 Dec 2006 09:38:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 39196-01 for ; Fri, 1 Dec 2006 09:37:56 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.233]) by postgresql.org (Postfix) with ESMTP id A768F9FA173 for ; Fri, 1 Dec 2006 09:37:56 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id i28so2946401wxd for ; Fri, 01 Dec 2006 05:37:55 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=tQ4O3/CW7+BZYglzfhGOje4iAwa/SEolT/8Ld4VD8/WzM7hXgDaM4NkvfbF2wWTI5NDDHiQFj1LmUIO8afuhkMiT2dLZo3Nk4f6+cTVQDfsiz1zMyn+1KCu7Zm+S1t+Bew+qy1gjEWCk4MrW6k6h4ZHjllcKShkh1xbid+m0SfY= Received: by 10.90.94.2 with SMTP id r2mr5013620agb.1164980275103; Fri, 01 Dec 2006 05:37:55 -0800 (PST) Received: by 10.90.65.3 with HTTP; Fri, 1 Dec 2006 05:37:55 -0800 (PST) Message-ID: <9d8bdcf30612010537o772b7aadu9c6e9125cdbc0d79@mail.gmail.com> Date: Sat, 2 Dec 2006 00:37:55 +1100 From: "Markus Juenemann" To: pgsql-sql@postgresql.org Subject: Set binary column dependent on cumulative value of integer column MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 59eecc3686db2ddc X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/3 X-Sequence-Number: 26959 Hi I've got a bit of a tricky (or me!) problem. The example below is completely ficticious but describes my real problem in a way which might be easier to understand. Imagine your table contains CREATE TABLE passenger_queue ( id serial NOT NULL, name character varying(40) NOT NULL,