Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAAVl-00057p-U3 for pgsql-sql@arkaria.postgresql.org; Wed, 19 Jan 2022 12:56:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAAVk-0000is-5B for pgsql-sql@arkaria.postgresql.org; Wed, 19 Jan 2022 12:56:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAAVj-0000iK-Qq for pgsql-sql@lists.postgresql.org; Wed, 19 Jan 2022 12:56:23 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nAAVh-00010g-Fs for pgsql-sql@lists.postgresql.org; Wed, 19 Jan 2022 12:56:23 +0000 Received: by mail-pg1-x536.google.com with SMTP id 187so2282539pga.10 for ; Wed, 19 Jan 2022 04:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=ma+QsxJEKolpd2nMNXCnk0Y5nckzyNe7I624lkn0sAQ=; b=hR1BA0y1/KUZi0ErO8lzpbyeJEeJOVqFrRbPdfgrk3bVJd8L2VjfH4FyABwmsvvqXA PB1CJqEKtEZPRdK8J51+HskMbObS2FePKavmMicP9U/p61hy2izG0Q7pZrnOvyp4LQFR 8QN49G5Bns/vqlLF2wCvKpoZbibf7UzyErRoA7JMbKjLUaMbtJ8mEcFc2e1bD8DAFTo3 sdKPAqeUi4Ux2YtCaD3jS/dG5s3YutvKQ2i64U2TY6xVIny7mGcZVKZ+tFlpi45yiV8r p5VIdG588BiEbFkcZCmButO0P+c1wCtYhu0UFxibrb3oJpbs6zLZb/I0T637g4uAYzuv OoXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=ma+QsxJEKolpd2nMNXCnk0Y5nckzyNe7I624lkn0sAQ=; b=awtS2CP3wiSE0WyoalZHDih2pO2oyLI0Eh2I6U/b/I7APIquZxeUplluZ/hztreq10 1rvzg1vqvKFrjscO18PLt+HQsnIa2mbdWoSMvOouKB/AJfeipYZrZCnrk3Ev13Wdt2Gh WKpCdcZ1KxSz5EdLDck/7zlysq0y9PZ4EXZGXUu9FOf8UAfAC/gNjYaYetndxzksM6KN I9rV0gqWghV8HQSc3aqavcI84pyS6mmOi7x30WQjyvLkyompp5ZbtODvbcqaLCZkkqJP PqPKK4IoYovjJFqu5o/qCsye6gpcaCGd5RsFBMznO4f9rxQLwjTrgUq2X/QD/T0SN+7o 8KkQ== X-Gm-Message-State: AOAM533tRIktPttNQXztaTdiQFi89m6ri/NNCzR2DjegBTOgReLWHib6 cqjGi5uCHujL7JIoYfQBwY2PQXEnS04= X-Google-Smtp-Source: ABdhPJzZ86S0qlu0P8nury5/mUPGrZKFMqppa0K3NXT6wyZOafgCw/h0lsAq+/K8CPzH4zkRYhOCRQ== X-Received: by 2002:a63:8c06:: with SMTP id m6mr26727153pgd.498.1642596978970; Wed, 19 Jan 2022 04:56:18 -0800 (PST) Received: from [10.0.0.94] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id k8sm22916248pfc.177.2022.01.19.04.56.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Jan 2022 04:56:18 -0800 (PST) Message-ID: <72f379a3-0bba-b0fb-975c-d20b76d33fff@gmail.com> Date: Wed, 19 Jan 2022 05:56:17 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: Clean up shop database Content-Language: en-CA To: pgsql-sql@lists.postgresql.org References: <20220119120317479683.54287f97@klingler.net> <9713782b-9c29-2497-be30-6dd1af0d550c@gmail.com> <20220119134059286538.4c015b19@klingler.net> From: Rob Sargent In-Reply-To: <20220119134059286538.4c015b19@klingler.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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' >