Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIJdW-0007vL-71 for pgsql-general@arkaria.postgresql.org; Thu, 01 Nov 2018 20:32:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIJdU-0001mj-9v for pgsql-general@arkaria.postgresql.org; Thu, 01 Nov 2018 20:32:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIJdT-0001mR-1G for pgsql-general@lists.postgresql.org; Thu, 01 Nov 2018 20:32:12 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIJdP-0007qO-RN for pgsql-general@postgresql.org; Thu, 01 Nov 2018 20:32:09 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id B65A721FAA; Thu, 1 Nov 2018 16:32:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 01 Nov 2018 16:32:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=F kGu8ZnCevHkTOqGQtcWYlD1ZJwzrIyp/oER2UUrRqM=; b=enevNHH0GCT858cu5 XEkJQNzpVtPs+v7AzN/JHbAWz0QSZPCo260dbRv1OiRZWJQfv15gQUgV5Q32AhWR fDPYzctqqAJA7Zg2i8I84ZByD+lPqdRKwnvAsFdiQGuYQKpxAvrek9g1EOCwsSaL XSJ3TGIf/xtoC6+bJqWgxXspkW3UsZkiRgGj57d57WIGS8TYTyhaO1c2PNgTcLbY W+cZqlwhrSwhNe9H57d4OkoWnhc2JgXwZCbGg6qITAXGM4FVwDn8Ggx0yBur9kT5 WE5Tj/N9cmWeCUH73pKorhNatB486+P4KDbjqtZfsSlqw/4wYRH76USmaHnAvLhB zl9DA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=FkGu8ZnCevHkTOqGQtcWYlD1ZJwzrIyp/oER2UUrR qM=; b=UQvp/hSTkhJ5oNcfkIXyatBit/9ObzOswCvTv0ki1+cu3wZQGvkxtgdmA DXrqUjZbt/Bim8aZr7C0umRH0NLgnM7joE+QKOzc+kHfa/jvfQwxe1fHO44H20eI k/iLnwAUXA4EmAkjbt417TMpIDHM1+jOUhuKiG074kwnfk1lyM8z/tcl2orniLYM rtf4rcIzMSi9uIprqWMKFkPW83kHNLogxzlN9QVlm0lqmz+Y6m/QWSOS64e5GnDG 6R8Iy5rWxFmiIR58WIpBuMkcle+lwILk03habPalskMdRZIDgpy1oWvo+PQGEm+x dQgdkB2NzbtLMzz+ImLcotLSlCGPg== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 2068A102E0; Thu, 1 Nov 2018 16:32:05 -0400 (EDT) Subject: Re: Add columns to table; insert values based on row To: Rich Shepard , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: Date: Thu, 1 Nov 2018 13:32:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/1/18 1:23 PM, Rich Shepard wrote: >   I have the following code in a script: > > alter table stations add column start_date date; > alter table stations add column end_date date; > alter table stations add column howmany integer; > alter table stations add column bin_col char(8); > > insert into stations (start_date, end_date, howmany, bin_col) values ( ) >   select site_nbr from stations >     where site_nbr = ' '; I am not following the above. Are you trying to add new data to existing records? If so where is the new data coming from? > >   The table has 82 rows. Is there a more elegant way to insert data > specific > to a site_nbr other than 82 repetitions of the insert statement? (I suspect > not, but I might be wrong and learn something valuable by asking.) > > Regards, > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com