CONCAT in Teradata
Teradata provides a concatenation operator that concatenates the data of different columns or strings to produces a readable result.
SELECT ('My name is ' || first_name || ' ' || last_name) FROM student
Definition and Usage
There is nothing like CONCAT function in Teradata. But Teradata provides the concatenation operator ('||') that combines the data of one or more columns or strings to print out the desired result.
Syntax
SELECT (string_1 || string_2 || string_n);
You may concatenate the data of any number of columns with this concatenation operator.
Argument Types
Argument | Description |
---|---|
string | It represents the data of columns or strings to concatenate. |
Result Value
This function returns a concatenated string which is a combination of many strings.
Examples:
For example, we have a student
table that contains id
, first_name
, last_name
, cgpa
fields.
student -------------------------- id first_name last_name cgpa 1 Amelia Liam 2.1 2 Harper Noah 2.6 3 Evelyn William 3.1 4 Abigail James 3.7 5 Emily Logan 2.2 6 Elizabeth Benjamin 3.5
Example 1:
The following query concatenates the the string with first_name, last_name, and cgpa to print our required result.
SELECT ('The CGPA of ' || first_name || ' ' || last_name || ' is ' || cgpa) FROM student;
Result:
The CGPA of Amelia Liam is 2.1 The CGPA of Harper Noah is 2.6 The CGPA of Evelyn William is 3.1 The CGPA of Abigail James is 3.7 The CGPA of Emily Logan is 2.2 The CGPA of Elizabeth Benjamin is 3.5
Summary
There is no Teradata CONCAT in Teradata. But there is a concatenation operator that concatenates the strings.
Tags
Was this article helpful?