scott martin
scott martin

Reputation: 1293

Redshift - Filter out rows that are blank to left or right of a character

I am trying to check for a condition that excludes rows that has a empty value either to the left of a hyphen (-) or to the right.

In the below sample, I need to filter out rows 2 and 3 since it is either blank to the left of the hyphen or to the right.

Trying to do this using Redshift.

Sample data:

data_set
apple - banana
 - banana
apple - 

Expected output:

data_set
apple - banana

Upvotes: 0

Views: 1190

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269563

You can use like:

where column like '%_-_%'

The _ is a wildcard that matches a character, but the character has to be there.

Note: You may need to trim the column value first, if spaces might appear before or after the hyphen.

Upvotes: 5

Related Questions