Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i76MP-0004OB-D9 for pgsql-general@arkaria.postgresql.org; Sun, 08 Sep 2019 23:12:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i76LN-0006SG-Cj for pgsql-general@arkaria.postgresql.org; Sun, 08 Sep 2019 23:11:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i76LM-0005zj-Sc for pgsql-general@lists.postgresql.org; Sun, 08 Sep 2019 23:11:41 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1i76LK-0002pN-6G for pgsql-general@lists.postgresql.org; Sun, 08 Sep 2019 23:11:39 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 46RRr85ytDz1hb9 for ; Sun, 8 Sep 2019 19:11:36 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 17622) id 46RRr84Vtvz1ZVM; Sun, 8 Sep 2019 19:11:36 -0400 (EDT) Date: Sun, 8 Sep 2019 19:11:36 -0400 From: stan To: pgsql-general@lists.postgresql.org Subject: help formualting a query Message-ID: <20190908231136.GA17798@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Editor: gVim User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I am having a hard time figuring out to do this, the SQL way. Doing in a procedural way with a foreach would be d=7Feasy, but I suspect that a properly formulated SQL query can achieve this. I have a table that contains a series of rows. Each row has a project key, a start date, and an end date. There are multiple rows with different start and end dates for each project. I need to return something that contains, one row per project key, with the min(star date) and max(end date) for ALL the records for that given project. Any suggestions? --=20 "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin