O'Reilly logo

Amazon Redshift: A Columnar Database SQL and Architecture by David Cook, Tom Coffing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required