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 1i76XC-0004oz-Jd for pgsql-general@arkaria.postgresql.org; Sun, 08 Sep 2019 23:23:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i76XB-00052t-7J for pgsql-general@arkaria.postgresql.org; Sun, 08 Sep 2019 23:23:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i76XA-0004tD-RS for pgsql-general@lists.postgresql.org; Sun, 08 Sep 2019 23:23:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i76X8-0003Ws-D2 for pgsql-general@lists.postgresql.org; Sun, 08 Sep 2019 23:23:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x88NNlHo022059; Sun, 8 Sep 2019 19:23:47 -0400 From: Tom Lane To: stan cc: pgsql-general@lists.postgresql.org Subject: Re: help formualting a query In-reply-to: <20190908231136.GA17798@panix.com> References: <20190908231136.GA17798@panix.com> Comments: In-reply-to stan message dated "Sun, 08 Sep 2019 19:11:36 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22057.1567985027.1@sss.pgh.pa.us> Date: Sun, 08 Sep 2019 19:23:47 -0400 Message-ID: <22058.1567985027@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk stan writes: > 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. Maybe I'm misunderstanding something, but isn't this just select project_key, min(start_date), max(end_date) from my_table group by project_key ?? regards, tom lane