Lets TRIM Some Data !!


TRIM

Syntax: TRIM ([ [ LEADING/TRAILING/BOTH] trim_character FROM] variable)

Parameters: Variable/trim_character -> String/Char/Number/Date type

Return Type: It returns VARCHAR2

Use Case
(i) If manager asks for the phone number and salary of the employees. But he wants to make sure that unneccary zero should not proceed in the phone number, if it exists.


SELECT FIRST_NAME,TRIM( LEADING 0 FROM SALARY)AS SALARY,TRIM(LEADING 0 FROM PHONE_NUMBER) FROM EMPLOYEES;


(ii) If manager wants email to do further computation. There might be unneccary blank spaces.


SELECT EMAIL,TRIM(LOWER(EMAIL)) FROM EMPLOYEES;



(iii) Manager wants to include address of employee in the report. But he doesn't want that extra blank space should not come in the report which would impact format.

SELECT TRIM (' ' FROM STREET_ADDRESS) FROM LOCATIONS;

Comments

Popular posts from this blog

Let's learn Cross Join!

Full Outer Join!

Let's extract STRING!