pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Why do I get these results?????
4+ messages / 2 participants
[nested] [flat]

* Why do I get these results?????
@ 2006-03-03 08:50  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  0 siblings, 2 replies; 4+ messages in thread

From: Joost Kraaijeveld @ 2006-03-03 08:50 UTC (permalink / raw)
  To: 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.Kraaijeveld@Askesis.nl
web: www.askesis.nl




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Why do I get these results?????
@ 2006-03-03 09:27  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  parent: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  1 sibling, 0 replies; 4+ messages in thread

From: Joost Kraaijeveld @ 2006-03-03 09:27 UTC (permalink / raw)
  To: Van Elsacker Frans <fve@atbib.be>; +Cc: pgsql-sql

Hi Frans

On Fri, 2006-03-03 at 10:06 +0100, Van Elsacker Frans wrote:
> Joost
> 
> Why do you use
> 
> AND TRIM(UPPER(addresses.city)) >= TRIM(UPPER('NIJMEGEN'))
> and not
> AND TRIM(UPPER(addresses.city)) = TRIM(UPPER('NIJMEGEN'))
> 
> upper(Rotterdam) en upper(Someren) meets >= TRIM(UPPER('NIJMEGEN'))
Because that is what I want:  I want everyone that is called "xxxx" and
lives in a city that is equal or larger than "yyyy". Jansen and Nijmegen
are just examples.

> commentline with order statements can not influence the content of the 
> result
What do you mean by that?

-- 
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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Why do I get these results?????
@ 2006-03-03 09:51  Ragnar <gnari@hive.is>
  parent: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  1 sibling, 1 reply; 4+ messages in thread

From: Ragnar @ 2006-03-03 09:51 UTC (permalink / raw)
  To: Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>; +Cc: pgsql-sql

On fös, 2006-03-03 at 09:50 +0100, Joost Kraaijeveld wrote:
> 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"

What LOCALE are you using?
Looks like it either sorts lowercase before uppercase
or treats them as equivalent.


Why do you not provide us with a simple test case?
Why involve a join and irrelevant columns?

What does a simple test like this do for you?:

test=# create table t (c text, n text);
CREATE TABLE
test=# insert into t values ('ROTTERDAM','jansen');
INSERT 33566780 1
test=# insert into t values ('SOMEREN','jansen');
INSERT 33566781 1
test=# insert into t values ('NIJMEGEN','Jansen');
INSERT 33566782 1
test=# insert into t values ('NIJMEGEN','Jansen');
INSERT 33566783 1
test=# insert into t values ('NIJMEGEN','Jansen');
INSERT 33566784 1
test=# select * from t ORDER BY n,c;
     c     |   n
-----------+--------
 NIJMEGEN  | Jansen
 NIJMEGEN  | Jansen
 NIJMEGEN  | Jansen
 ROTTERDAM | jansen
 SOMEREN   | jansen
(5 rows)

(this in in C locale)

gnari





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Why do I get these results?????
@ 2006-03-03 10:42  Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
  parent: Ragnar <gnari@hive.is>
  0 siblings, 0 replies; 4+ messages in thread

From: Joost Kraaijeveld @ 2006-03-03 10:42 UTC (permalink / raw)
  To: Ragnar <gnari@hive.is>; +Cc: pgsql-sql

On Fri, 2006-03-03 at 09:51 +0000, Ragnar wrote:
> Looks like it either sorts lowercase before uppercase
> or treats them as equivalent.
Ooops. I must sort resultset using the same condition is I select. Oops
again. them.....

-- 
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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2006-03-03 10:42 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-03-03 08:50 Why do I get these results????? Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2006-03-03 09:27 ` Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>
2006-03-03 09:51 ` Ragnar <gnari@hive.is>
2006-03-03 10:42   ` Joost Kraaijeveld <J.Kraaijeveld@Askesis.nl>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox