Sorting when "*" is the initial character

From: "Berend Tober" <btober(at)seaworthysys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Sorting when "*" is the initial character
Date: 2005-02-07 21:20:36
Message-ID: 63142.216.238.112.88.1107811236.squirrel@216.238.112.88
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I encountered what looks like unusually sorting behavior, and I'm wondering if
anyone can tell me if this is supposted to happen (and then if so, why) or if
this is a bug:

CREATE TABLE sample_table
(
account_id varchar(4),
account_name varchar(25)
)
WITHOUT OIDS;

INSERT INTO sample_table VALUES ('100', 'First account');
INSERT INTO sample_table VALUES ('110', 'Second account');
INSERT INTO sample_table VALUES ('120', 'Third account');
INSERT INTO sample_table VALUES ('*125', 'Fourth account');
INSERT INTO sample_table VALUES ('*115', 'Fifth account');

SELECT * FROM sample_table ORDER BY 1;

account_id,account_name
100,First account
110,Second account
*115,Fifth account
120,Third account
*125,Fourth account

I would expect to see

account_id,account_name
*115,Fifth account
*125,Fourth account
100,First account
110,Second account
120,Third account

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2005-02-07 21:40:40 Re: Creating an index-type for LIKE '%value%'
Previous Message Larry Rosenman 2005-02-07 21:16:51 Re: Creating an index-type for LIKE '%value%'