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 1q3zlL-0004bL-Rq for pgsql-general@arkaria.postgresql.org; Tue, 30 May 2023 13:51:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q3zlK-00065F-NQ for pgsql-general@arkaria.postgresql.org; Tue, 30 May 2023 13:51:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q3zlK-000656-BO for pgsql-general@lists.postgresql.org; Tue, 30 May 2023 13:51:46 +0000 Received: from srv01.teladesign.ie ([2001:41c9:1:41d::10]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q3zlH-002iA1-Ba for pgsql-general@lists.postgresql.org; Tue, 30 May 2023 13:51:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rodonnell.ie; s=exim; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: From:References:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Message-ID; bh=xhB4wfu8ie2J6N56Ol2SK0gUfJs6AAgz8UXfM14l9l8=; b=JflKr1WL0OfOO654S7JlFdR+h7 Ma2UBXmFUORnvDaztztVm3RHE8Vap1h0AMOiOJ79ktz6aW1x/IdFf9mLpKOPJueKamxs4q++Twv9B F8Lm2D44kv1jYW2xZCXv2A+FJeDtAW5lKrBfxIlLMU9mWcDzRfW59eYHOrxKswQ05Kx8=; Received: from [86.43.85.86] (helo=[192.168.1.31]) by srv01.teladesign.ie with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1q3zl9-0006oX-5P; Tue, 30 May 2023 14:51:37 +0100 Message-ID: Date: Tue, 30 May 2023 14:51:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: syntax pb Content-Language: en-GB To: Marc Millas , "pgsql-general@lists.postgresql.org" References: From: Ray O'Donnell In-Reply-To: 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 30/05/2023 14:45, Marc Millas wrote: > and , now, if I want to insert that: > Insert into t2 (a, b, c, d) > Select distinct test1.t, 'abc' as b, NULL as c, NULL as d > From t1 test1; > > I get: > ERROR:  column "d" is of type numeric but expression is of type text > LINE 2: Select distinct test1.t, 'abc' as b, NULL as c, NULL as d > > HINT:  You will need to rewrite or cast the expression. I'm guessing you'll need to cast the NULLs: .... select distinct test1.t, 'abc', null::text, null::numeric ... I don't think you need the aliases. Ray. > > Can someone give a short SQL syntax hint ? > > thanks, > > > > Marc MILLAS > Senior Architect > +33607850334 > www.mokadb.com > -- Raymond O'Donnell // Galway // Ireland ray@rodonnell.ie