Re: Clean up shop database - Mailing list pgsql-sql

From Rob Sargent
Subject Re: Clean up shop database
Date
Msg-id 72f379a3-0bba-b0fb-975c-d20b76d33fff@gmail.com
Whole thread Raw
In response to Re: Clean up shop database  (Richard Klingler <richard@klingler.net>)
Responses Re: Clean up shop database
List pgsql-sql
On 1/19/22 05:40, Richard Klingler wrote:
> Odd...gives me the same result....
>
> Tried another approach as the ordered is known where to start
> from....but still the same:
>
> select p.productid as id, p.name_de as name
> from product p, orderitems i,orders
> where p.productid = i.orderitems2productid
> and i.orderitems2orderid = orders.orderid
> and orders.orderid < 14483
> and p.pieces < 1
> and p.active = 't'
> group by id
> order by id desc
>
> Still lists products after January 1st 2021...but I know what is going
> on....

(On this list top-posting is frowned upon.  Inline or bottom-posting 
preferred.)
The above query does not restrict order date?

select p.*,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'

>




pgsql-sql by date:

Previous
From: Richard Klingler
Date:
Subject: Re: Clean up shop database
Next
From: Richard Klingler
Date:
Subject: Re: Clean up shop database