Sai
Sai

Reputation: 689

Rtrim in oracle

i'm using below query

select rtrim(ename,substr(ename,2,10))||'->'||ename from emp order by ename;

to get below output

A->ALLEN
A->AMITH
B->BlAKE
S->SMITH ...... etc

but i am getting output like

 ->ALLEN
A->AMITH
B->BlAKE
S->SMITH

Any suggetions please, am i missing any thing? . Why the letter "A" in first line was missing.

Upvotes: 0

Views: 241

Answers (2)

Harvinder Kheng
Harvinder Kheng

Reputation: 44

SELECT SUBSTRING(ename,1,1) + '->' + ename FROM SAMPLE ORDER BY ename;

I have tried the above mentioned Query in SQL Server and its working fine.

Upvotes: 0

Noam Rathaus
Noam Rathaus

Reputation: 5598

Why not use

select SUBSTR(ename,1,1))||'->'||ename from emp order by ename;

It will return the first letter of each name

Upvotes: 4

Related Questions