DB2 SQL: LTRIM, RTRIM and TRIM best examples

DB2 String Functions

Functions are an important concept in DB2. Look for job requirement for data warehousing jobs. If we want to make a report from the data, we use built-in functions to get required output. It simplifies your SQL query.

Advertisements

There are many examples. I am giving my own examples.

“RAMA RAGAVA RANI  “

SELECT RTRIM(“RAMA RAGAVA RANI  “) FROM SYSIBM.SYSDUMM1  …> You will get result “RAMA RAGAVA RANI “. Means it removes space on right side.

”  RAMA RAGAVA RANI  “

SELECT LTRIM(” RAMA RAGAVA RANI”) FROM SYSIBM.SYSDUMM1  …> You will get result “RAMA RAGAVA RANI “. Means it removes space on left side.

”  RAMA RAGAVA RANI “

SELECT TRIM(” RAMA RAGAVA RANI “) FROM SYSIBM.SYSDUMM1  …> You will get result “RAMA RAGAVA RANI “. Means it removes space on both sides.

The above are beautiful examples. You can use extensively. Refer more built in functions here.

References

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.