Reputation: 689
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
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
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