Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YU4yM-0000Rf-88 for pgsql-sql@arkaria.postgresql.org; Sat, 07 Mar 2015 03:00:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YU4yL-0005CM-Ig for pgsql-sql@arkaria.postgresql.org; Sat, 07 Mar 2015 03:00:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YU4yK-000590-6q for pgsql-sql@postgresql.org; Sat, 07 Mar 2015 03:00:12 +0000 Received: from mwork.nabble.com ([162.253.133.43]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YU4yG-0007rr-Sq for pgsql-sql@postgresql.org; Sat, 07 Mar 2015 03:00:10 +0000 Received: from msam.nabble.com (unknown [162.253.133.85]) by mwork.nabble.com (Postfix) with ESMTP id 1E9B01634353 for ; Fri, 6 Mar 2015 19:00:11 -0800 (PST) Date: Fri, 6 Mar 2015 20:00:07 -0700 (MST) From: David G Johnston To: pgsql-sql@postgresql.org Message-ID: <1425697207404-5840891.post@n5.nabble.com> In-Reply-To: <54FA1E61.9000201@gmail.com> References: <54FA1E61.9000201@gmail.com> Subject: Re: Find inconsistencies in data with date range MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Jason Aleksi wrote > I've looked at some procedure codes regarding looping, but everything I > try to create seems to give me problems. THe code I'm trying is also > below. Does anyone have any suggestions on how to accomplish this? I would build a master table of stores and dates and then write a query to update a third field from null to the number of records found for the given combination. When all the nulls are gone you can scan for zeros to figure out what combinations are missing data. If you have a matching index the queries should execute reasonably efficiently and you either call it from a function in the database or externally on one or more threads depending on where you expect to encounter the processing bottleneck. You can process more than one day or store at a time if so desired but there will likely be a point of diminishing returns depending on the volume of data. I would probably do all days for one store in a given year at a time. David J. -- View this message in context: http://postgresql.nabble.com/Find-inconsistencies-in-data-with-date-range-tp5840865p5840891.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql