Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2D5C39FBB9D for ; Tue, 29 May 2007 14:47:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 39312-06 for ; Tue, 29 May 2007 14:47:30 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 401D49FBAD7 for ; Tue, 29 May 2007 14:47:30 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from randymail-a8.g.dreamhost.com (mailbigip.dreamhost.com [208.97.132.5]) by svr4.postgresql.org (Postfix) with ESMTP id 2C9495AF04F for ; Tue, 29 May 2007 17:47:29 +0000 (GMT) Received: from [10.37.75.125] (unknown [204.252.154.241]) by randymail-a8.g.dreamhost.com (Postfix) with ESMTP id BE3B0AF658; Tue, 29 May 2007 10:47:26 -0700 (PDT) Message-ID: <465C6705.5000505@joshuaneil.com> Date: Tue, 29 May 2007 12:46:45 -0500 From: Joshua User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Richard Huxton Cc: pgsql-sql@postgresql.org Subject: Re: problems with SELECT query results References: <465C4B0B.4070906@joshuaneil.com> <465C5671.50907@archonet.com> In-Reply-To: <465C5671.50907@archonet.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.171 tagged_above=0 required=5 tests=AWL=0.170, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200705/187 X-Sequence-Number: 28467 Hello, Thank you all for your assistance. I did end up finding NULL in the 'onorder' column which should have been zero's.... this was in a test table that happened to have some NULL in it for one reason or another but I should not find this in the production version of the table. I also appreciate you pointing out the COALESCE function. I will find that helpful in future work. I look forward to hopefully assisting you guys with some of your PostgreSQL dilemmas in the future! Thanks again!!! -Joshua Richard Huxton wrote: > Joshua wrote: >> Hello, >> >> I am new to this list and have been working with PostgreSQL since >> January. >> >> Here is my problem, I hope someone here has some experience or can >> point me in the right direction. I am writing the following query for >> a C# program I am writing: >> >> SELECT 'PV.LINEITEM:' || partnum || ',' || round(onhand) || ',' || >> round(qm5) || ',' || round(lsm4) || ',' || ',' || ',' || >> round(onorder) || ',' || ',' || ',' || binone || ',' || ',' || >> round(backorderqty) || ',' || ',' || round(onhold) || ',' || ',' || >> ',' || ',' || ',' || ',' || ',' || round(qtyperjob) || ',' || >> round(ordermax) AS gmrim FROM slparts WHERE vendor LIKE 'CH%' >> >> The query does work and I am getting results from the database. There >> are values for all 'partnum' in the database, however, the query >> results include blank fields here and there in between the returned >> records. Why am I receiving blank fields for 'gmrim'???? This >> absolutely defies logic and I cannot find any rhyme or reason for >> this problem. I cannot have any blank rows in the query, and again >> the database is completely populated with values. > > I'm not sure it is - I think you've got a NULL somewhere. > > Since NULL means "unknown" ('text' || NULL) = NULL > > Wrap all your column-references in COALESCE: e.g. COALESCE(partnum,'') > and see if that solves it. If so, go back and find rows WHERE partnum > IS NULL and correct them. Then set the NOT NULL constraint on the > relevant columns. >