Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting each max character of a string column?

1061471Dec 20 2013 — edited Dec 20 2013

Hello,

I have a group of rows with a string field, as in the example:

Row #1: "AJDEKB"

Row #2: "DHEJKS"

Row #3: "JEKRSQ"

...

and I need to get the greatest character of each position in the string.

In the example, the result should be: "JJKRSS"

I achieve that result by taking each cahracter as a substring and using the MAX group function:

SELECT MAX(SUBSTR(COL1, 1, 1)) || MAX(SUBSTR(COL1, 2, 1) || MAX(SUBSTR(COL1, 3, 1) || ...

but as the real string is very long, I get a very very long query as a result.

Does anybody know a better way to do this?

Thanks in advance.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 17 2014
Added on Dec 20 2013
5 comments
2,286 views