Patrick
Patrick

Reputation:

Order a select result case insensitively?

Is it possible to order the result of select query on a db2 database case insensitively?

For example: I want to have all names that start with an "a" or "A" sorted together.

Abraham
aron
andrea
Annica
brian
Benjamin

Now it's like this:

aron
andrea
brian
Abraham
Annica
Benjamin

Upvotes: 2

Views: 2402

Answers (2)

Walden Leverich
Walden Leverich

Reputation: 4546

Assuming you're on DB2/400 (assuming from another post of yours) then you'd want to change the sort sequence of the job requesting that query to be SRTSEQ(*LANGIDSHR). You can also (and should) build an index w/that setting so there's an index to use.

Running the lower() function will force DB2 to evaluate the function for each row and build a huge temp table to handle it. It will work... but work poorly.

Upvotes: 1

tpdi
tpdi

Reputation: 35141

order by lower(columnname);

Upvotes: 9

Related Questions