X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id D66229DC82A for ; Fri, 3 Mar 2006 04:50:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98303-09 for ; Fri, 3 Mar 2006 04:50:45 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) by postgresql.org (Postfix) with ESMTP id EBDC59DC806 for ; Fri, 3 Mar 2006 04:50:40 -0400 (AST) Received: obelix 172.31.0.1 from 172.31.1.4 172.31.1.4 via HTTP with MS-WebStorage 6.0.6249 Received: from panoramix by obelix; 03 Mar 2006 09:50:40 +0100 Subject: Why do I get these results????? From: Joost Kraaijeveld To: Pgsql-Sql Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Fri, 03 Mar 2006 09:50:40 +0100 Message-Id: <1141375840.4267.16.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.4.2.1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.081 required=5 tests=[AWL=0.080, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.081 X-Spam-Level: X-Archive-Number: 200603/61 X-Sequence-Number: 24407 Hi, Why do I get the following result from the query below? I expected that, given the fact that there are over 100 "Jansen" (but no "jansen") in "Nijmegen" the first record would definitively be people living in "Nijmegen". If I change the order to the order that is commented out, the query goes OK. SELECT addresses.zipcode, addresses.city, addresses.housenumber, addresses.housenumberdetails, customers.lastname FROM prototype.customers JOIN prototype.addresses ON customers.contactaddress = addresses.objectid WHERE TRIM(UPPER(customers.lastname)) >= TRIM(UPPER('Jansen')) AND TRIM(UPPER(addresses.city)) >= TRIM(UPPER('NIJMEGEN')) ORDER BY customers.lastname, addresses.city, addresses.zipcode --ORDER BY addresses.city, customers.lastname, addresses.zipcode limit 5 Result: "3089TN";"ROTTERDAM";"5";"";"jansen" "5712XG";"SOMEREN";"13";"";"jansen" "6511PS";"NIJMEGEN";"23";"";"Jansen" "6523RE";"NIJMEGEN";"13";"";"Jansen" "6524NP";"NIJMEGEN";"37";"A";"Jansen" TIA -- Groeten, Joost Kraaijeveld Askesis B.V. Molukkenstraat 14 6524NB Nijmegen tel: 024-3888063 / 06-51855277 fax: 024-3608416 e-mail: J.Kraaijeveld@Askesis.nl web: www.askesis.nl