views:

282

answers:

2

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
+5  A: 
order by lower(columnname);
tpdi
A: 

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.

WaldenL