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 1iSmB2-0001uZ-NM for pgsql-sql@arkaria.postgresql.org; Thu, 07 Nov 2019 18:06:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iSmB1-0007k9-Fl for pgsql-sql@arkaria.postgresql.org; Thu, 07 Nov 2019 18:06:35 +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 1iSmB1-0007k2-7r for pgsql-sql@lists.postgresql.org; Thu, 07 Nov 2019 18:06:35 +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 1iSmAz-0002ij-1B for pgsql-sql@lists.postgresql.org; Thu, 07 Nov 2019 18:06:34 +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 xA7I6Vqb015360; Thu, 7 Nov 2019 13:06:31 -0500 From: Tom Lane To: "Tchouante, Merlin" cc: "pgsql-sql@lists.postgresql.org" Subject: Re: Returned row count doesn't match lines in output file In-reply-to: References: Comments: In-reply-to "Tchouante, Merlin" message dated "Thu, 07 Nov 2019 17:57:16 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15358.1573149991.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 07 Nov 2019 13:06:31 -0500 Message-ID: <15359.1573149991@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Tchouante, Merlin" writes: > I'm executing an .sql file which looks like this: > \o /home/bbuser/banner/gradeload/sodorgusers.txt > \t on > select u.user_id||'|'||u.firstname||'|'||u.lastname||'|'||u.email||'|'||= u.student_id > from users u, course_main cm, course_users cu > where cu.crsmain_pk1 =3D cm.pk1 > and cu.users_pk1 =3D u.pk1 > and cm.course_id =3D 'Org.dent.Training' > order by u.lastname, u.firstname; > \t off > \o > When I look at the output file, it has a bunch of blank lines in between= the records but displays a line count of 4916. What is causing the blank= lines? Null values in one or more of the columns you're concatenating, perhaps? Concatenating a null with something else yields null. (See coalesce() for one ad-hoc way to fix that.) regards, tom lane