Chapter 16 - Substrings and Positioning Functions

“It’s always been and always will be the same in the world: the horse does the work and the coachman is tipped.”

- Anonymous

The TRIM Command trims both Leading and Trailing Spaces

Query 1

SELECT Last_Name

              ,Trim(Last_Name) AS No_Spaces

FROM    Employee_Table ;

Query 2

SELECT Last_Name

             ,Trim(Both from Last_Name) AS No_Spaces

FROM    Employee_Table ;

Both queries above do the exact same thing. They remove spaces from the beginning and the end of the column Last_Name.

Both queries trim both the leading and trailing spaces from Last_Name.

A Visual of the TRIM Command Using Concatenation

When you use the TRIM command on a column, that column will have all beginning ...

Get Amazon Redshift: A Columnar Database SQL and Architecture now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.