Need Correct Filter for Query

Database

Need Correct Filter for Query

I'm new to writing queries so please, so be kind please.... I'm attempting to write a query to list all names in the database that has either the first name or last name with a length longer than 12 characters. I'm not sure how to write that query to include both. Any help will be greatly appreciated...

 

Example: 

Select first_name,

           last_name,

From  this_table

Where length(last_name) > 12

 

Now what?         


Accepted Solutions
Enthusiast

Re: Need Correct Filter for Query

You might want to use trim as well as below:

 

select first_name

,last_namme

from this_table

where character_length(trim(first_name))>12

or character_length(trim(last_name))>12

 

then again, it depends on your requirements.

1 ACCEPTED SOLUTION
3 REPLIES
Enthusiast

Re: Need Correct Filter for Query

select first_name

,last_namme

from this_table

where character_length(first_name)>12

or character_length(last_name)>12

Tags (1)
Enthusiast

Re: Need Correct Filter for Query

You might want to use trim as well as below:

 

select first_name

,last_namme

from this_table

where character_length(trim(first_name))>12

or character_length(trim(last_name))>12

 

then again, it depends on your requirements.

Re: Need Correct Filter for Query

Thanks! I wasn't sure if 'OR' was available in teradata query. And yes, trim is needed.