Re: ORDER BY and ignoring the , a , and an - Mailing list pgsql-general

From Doug McNaught
Subject Re: ORDER BY and ignoring the , a , and an
Date
Msg-id m366gsqqzy.fsf@belphigor.mcnaught.org
Whole thread Raw
In response to ORDER BY and ignoring the , a , and an  ("Stoppel, Brett W" <bstoppel@ku.edu>)
List pgsql-general
"Stoppel, Brett W" <bstoppel@ku.edu> writes:

> Is it possible to have the ORDER BY option ignore the articles "the ", "a ",
> and "an " at the beginning of a VARCHAR, CHAR, TEXT, et cetera field? In
> other words, I want my results to come back alphabetized, while ignoring the
> aforementioned articles.

Only way I can think of would be to write a function to do the
stripping yourself, say 'strip_articles(text) RETURNS text' and then
in your SELECTS, do 'ORDER BY strip_articles(mycolumn)'.  For
performance you might also want to create an index on that same
expression.

You could write the function in any of the available server-side
languages (pgsql, perl, tcl).

-Doug

pgsql-general by date:

Previous
From: Dave Perkins
Date:
Subject: Re: missing data
Next
From: Peter Eisentraut
Date:
Subject: Re: missing data