agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Rob Sargent <robjsargent@gmail.com>
To: pgsql-sql@lists.postgresql.org
Subject: Re: Clean up shop database
Date: Wed, 19 Jan 2022 09:41:29 -0700
Message-ID: <6295d658-71b9-79b9-17cc-36c5525673cc@gmail.com> (raw)
In-Reply-To: <20220119145738389655.606222b1@klingler.net>
References: <20220119143718285650.48772b27@klingler.net>
<43C34BCB-1690-40DE-852F-72D289096CB2@gmail.com>
<20220119145738389655.606222b1@klingler.net>
> Hmm..almost forgot.....
>
> Now how would I turn this into an update statement based on the
> previous query?
>
update what? A CTE comes to mind but maybe
update product p set some=thing
where p.productid = m.productid
from (select p.productid,max(o.orderdate)
from product p join orderitem t on p.productid = t.orderitems2productid
join order o on t.orderitems2orderid = o.orderid
group by p.productid
having max(o.orderdate < 'January 1 2021') as m
view thread (12+ messages)
Message-ID: <6295d658-71b9-79b9-17cc-36c5525673cc@gmail.com>
Permalink: ../6295d658-71b9-79b9-17cc-36c5525673cc@gmail.com/
Also on: postgresql.org/message-id/6295d658-71b9-79b9-17cc-36c5525673cc@gmail.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: robjsargent@gmail.com, pgsql-sql@lists.postgresql.org
Subject: Re: Clean up shop database
In-Reply-To: <6295d658-71b9-79b9-17cc-36c5525673cc@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox