Pages

31 July 2016

SQL- Scenario Based Questions PART- 5

SCENARIO:  We have table EMPLOYEE_INFO  which contains Employee information. We want the output table should display NAME field and it should contain EMPNAME field values leaving behind first and last character in it. Please see below in details.


TABLE NAME: EMPLOYEE_INFO

EMPLOYEE_INFO Table

EXPECTED RESULT:

EMPLOYEE_INFO Table

SOLUTION:


We can get this done by using the combination of Oracle string functions SUBSTR and LENGTH  as below .

SELECT EMPID ,EMPNMAE,EMAILID,AGE,GENDER,
SUBSTR(EMPNMAE,2,LENGTH(EMPNMAE)-2) Name FROM EMPLOYEE_INFO;

EMPLOYEE_INFO Table


No comments:

Post a Comment