Re: Sorting when "*" is the initial character
От
CoL
Тема
Re: Sorting when "*" is the initial character
Дата
Msg-id
cu96rj$20i6$1@news.hub.org
Ответ на
Sorting when "*" is the initial character (Berend Tober)
Список
Дерево обсуждения
Sorting when "*" is the initial character "Berend Tober" <btober@seaworthysys.com>
Re: Sorting when "*" is the initial character Stephan Szabo <sszabo@megazone.bigpanda.com>
Re: Sorting when "*" is the initial character Bruno Wolff III <bruno@wolff.to>
Re: Sorting when "*" is the initial character CoL <col@mportal.hu>
Re: Sorting when "*" is the initial character Russell Smith <mr-russ@pws.com.au>
Re: Sorting when '*' is the initial character - solved "Berend Tober" <btober@seaworthysys.com>
hi,
Berend Tober wrote, On 2/7/2005 22:20:
> 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
order by case when account_id like '*%' then 0 else 1 end
C.
В списке pgsql-general по дате отправления