Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A3E4537C2C3 for ; Mon, 6 Oct 2008 05:51:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 02851-01 for ; Mon, 6 Oct 2008 05:51:05 -0300 (ADT) X-Greylist: delayed 00:18:36.978676 by SQLgrey-1.7.6 Received: from BRUBLUmx13.mactelecom.net (BRUBLUmx13.mactelecom.net [217.64.240.20]) by postgresql.org (Postfix) with ESMTP id 4B26737B9B7 for ; Mon, 6 Oct 2008 05:51:05 -0300 (ADT) Received: by BRUBLUmx13.mactelecom.net (Postfix, from userid 505) id 90BF0211C28; Mon, 6 Oct 2008 10:32:22 +0200 (CEST) Received: from smtp.eurofer.be (217.64.254.218.mactelecom.net [217.64.254.218]) by BRUBLUmx13.mactelecom.net (Postfix) with ESMTP id 51CBD211C25 for ; Mon, 6 Oct 2008 10:32:22 +0200 (CEST) Received: from [192.168.5.30] by smtp.eurofer.be with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1KmlVf-0005tp-TP for pgsql-admin@postgresql.org; Mon, 06 Oct 2008 10:32:22 +0200 Message-ID: <48E9CD06.4030307@eurofer.be> Date: Mon, 06 Oct 2008 10:32:06 +0200 From: Guy Deleeuw User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 To: pgsql-admin@postgresql.org References: <864f9e230810040547j62e8d50cs6d30932d9f4c1f0@mail.gmail.com> <48E774A7.2020409@eurofer.be> <864f9e230810040653o7ef5a1c5l20ea3946545dc323@mail.gmail.com> In-Reply-To: <864f9e230810040653o7ef5a1c5l20ea3946545dc323@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam_score: -3.7 X-SA-Exim-Connect-IP: 192.168.5.30 X-SA-Exim-Mail-From: G.De_Leeuw@eurofer.be Subject: sql command strange behaviour X-SA-Exim-Scanned: Yes (on smtp.eurofer.be) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200810/23 X-Sequence-Number: 30479 Hello the list I have a problem with an sql command and I not understand what is happens. I execute this query and the result is ok : db_stats=# SELECT code, label, typecumul FROM table_f801_cat_period INNER JOIN table_cat_period USING (code) WHERE typecumul = 0 EXCEPT SELECT code_base, label, typecumul FROM (SELECT code_base FROM table_cat_period_tcodes INNER JOIN table_f801_cat_period ON (code_cumul=code)) AS orphan_f801 INNER JOIN table_cat_period ON (code_base=code) ORDER BY code; code | label | typecumul ----------+----------+----------- 20080799 | Jul 2008 | 0 (1 ligne) db_stats=# Now I execute this query that request one column more, the "ind" field., the return of this query is bad. db_stats=# SELECT code, label, typecumul, ind FROM table_f801_cat_period INNER JOIN table_cat_period USING (code) WHERE typecumul = 0 EXCEPT SELECT code_base, label, typecumul, ind FROM (SELECT code_base, ind FROM table_cat_period_tcodes INNER JOIN table_f801_cat_period ON (code_cumul=code) AND (ind=ind)) AS orphan_f801 INNER JOIN table_cat_period ON (code_base=code) ORDER BY ind, code; code | label | typecumul | ind ----------+----------+-----------+----- 20040199 | Jan 2004 | 0 | 0 20040299 | Feb 2004 | 0 | 1 20040399 | Mar 2004 | 0 | 2 20040499 | Apr 2004 | 0 | 4 20040599 | May 2004 | 0 | 5 20040699 | Jun 2004 | 0 | 6 20040799 | Jul 2004 | 0 | 9 20040899 | Aug 2004 | 0 | 10 20040999 | Sep 2004 | 0 | 11 20041099 | Oct 2004 | 0 | 13 20041199 | Nov 2004 | 0 | 14 20041299 | Dec 2004 | 0 | 15 20050199 | Jan 2005 | 0 | 19 20050299 | Feb 2005 | 0 | 20 20050399 | Mar 2005 | 0 | 21 20050499 | Apr 2005 | 0 | 23 20050599 | May 2005 | 0 | 24 20050699 | Jun 2005 | 0 | 25 20050799 | Jul 2005 | 0 | 28 20050899 | Aug 2005 | 0 | 29 20050999 | Sep 2005 | 0 | 30 20051099 | Oct 2005 | 0 | 32 20051199 | Nov 2005 | 0 | 33 20051299 | Dec 2005 | 0 | 34 20060199 | Jan 2006 | 0 | 38 20060299 | Feb 2006 | 0 | 39 20060399 | Mar 2006 | 0 | 40 20060499 | Apr 2006 | 0 | 42 20060599 | May 2006 | 0 | 43 20060699 | Jun 2006 | 0 | 44 20060799 | Jul 2006 | 0 | 47 20060899 | Aug 2006 | 0 | 48 20060999 | Sep 2006 | 0 | 49 20061099 | Oct 2006 | 0 | 51 20061199 | Nov 2006 | 0 | 52 20061299 | Dec 2006 | 0 | 53 20070199 | Jan 2007 | 0 | 57 20070299 | Feb 2007 | 0 | 58 20070399 | Mar 2007 | 0 | 59 20070499 | Apr 2007 | 0 | 61 20070599 | May 2007 | 0 | 62 20070699 | Jun 2007 | 0 | 63 20070799 | Jul 2007 | 0 | 66 20070899 | Aug 2007 | 0 | 67 20070999 | Sep 2007 | 0 | 68 20071099 | Oct 2007 | 0 | 70 20071199 | Nov 2007 | 0 | 71 20071299 | Dec 2007 | 0 | 72 20080199 | Jan 2008 | 0 | 76 20080299 | Feb 2008 | 0 | 77 20080399 | Mar 2008 | 0 | 78 20080499 | Apr 2008 | 0 | 80 20080599 | May 2008 | 0 | 81 20080699 | Jun 2008 | 0 | 82 20080799 | Jul 2008 | 0 | 85 (55 lignes) db_stats=# if anyone have an idea ... Thanks in advance Guy