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

From Mike Sofen
Subject RE: Clean up shop database
Date
Msg-id 122401d80d3b$ba859da0$2f90d8e0$@runbox.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
> From: Richard Klingler <richard@klingler.net>  Sent: Wednesday, January
19, 2022 5:37 AM
> On Wed, 19 Jan 2022 06:32:19 -0700, Rob Sargent wrote:
> > 
> >> No it does not...but I assume it lists products that where at least 
> >> ordered before January 1st 2021 as it contains lower product IDs.
> >> 
> >> Hmm..gives me:
> >> 
> >>> ERROR:  function max(boolean) does not exist
> >> LINE 5: having max(o.orderdate < '2021-01-01')
> >> 
> >> 
> > Sorry
> >> 
> >> max(o.orderdate )< '2021-01-01'
> > 
> >> 

> You're a genius :-)

> Looks perfect...

There is one caveat here: unless you are 100% certain that the
product.pieces count is 100% accurate, you should sum the
orderitems.productid.  It is pretty common for the indirect counts (like
product.pieces) to get out of sync with the "normal" source of truth (line
items).  

This does depend on design of your system, of course.

Mike






pgsql-sql by date:

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