简体   繁体   中英

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.

Why not use

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

It will return the first letter of each name

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

我已经在SQL Server中尝试了上述查询,并且其工作正常。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM