To find maximum length in a column in Teradata

In Teradata, you can find the maximum length of a string in a column like below:

Syntax:
SELECT MAX(LENGTH(column_name)) FROM table_name;


Note:
You can get the results accurately for string/VARCHAR columns.
For INT columns the results may not be accurate.

Example:

Consider, A column 'name VARCHAR(20)' defined in a table employee and it has the following values
Name
ABC
ABCD
ABCDE
ABCDEF

SELECT MAX(LENGTH(name)) FROM employee;


Output:
6

How it does actually ?
1. First it will trim the input.
2. It will compute the total characters.
3. It will choose the maximum value.
MAX(CHARACTERS(TRIM(column)))


Example:
Select the record(s) from the table tbl_emp whose employee name is very large.
SELECT * FROM tbl_emp
WHERE
LENGTH(emp_name) = (SELECT MAX(LENGTH(emp_name)) FROM tbl_emp)