Devashri B.
Devashri B.

Reputation: 2703

Oracle - Count with letters instead of numbers

I want to convert count to Letter in Oracle.Currently I am using below query.

SELECT DECODE ((SELECT COUNT(*)FROM MyTable), 0, 'A',
                                                      1, 'B',
                                                      2, 'C',
                                                      3, 'D',
                                                      4, 'E',
                                                      5, 'F',
                                                      6, 'G',
                                                      7, 'H') 
FROM DUAL;

Is there any particular oracle function which converts digit to letter.

Upvotes: 3

Views: 115

Answers (2)

Dr. Debasish Jana
Dr. Debasish Jana

Reputation: 7118

You may use CHR(48+d), where d is the digit 0, 1, 2 etc

Upvotes: 1

Andrew Morton
Andrew Morton

Reputation: 25013

My syntax may be wrong, but the CHR function is what you're after...

SELECT CHR(65 + COUNT(*)) FROM MyTable

...assuming you are using a character set in which "A" has a code of 65 and the letters are sequential after that.

Upvotes: 5

Related Questions