Why do I get these results?????

From: Joost Kraaijeveld <J(dot)Kraaijeveld(at)Askesis(dot)nl>
To: Pgsql-Sql <Pgsql-sql(at)postgresql(dot)org>
Subject: Why do I get these results?????
Date: 2006-03-03 08:50:40
Message-ID: 1141375840.4267.16.camel@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(dot)Kraaijeveld(at)Askesis(dot)nl
web: www.askesis.nl

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joost Kraaijeveld 2006-03-03 09:27:50 Re: Why do I get these results?????
Previous Message Gregory S. Williamson 2006-03-03 07:37:53 Re: Sequential scan where Index scan expected (update)