Things under legendu
**
Things under legendu
Syntax¶
Each Teradata SQL statement must be ended by a semicolon.
The keyword
inneris optional in aninner join.To estimate the time and space complexity, you can prefix your SQL code by
explain, or you can just press theExplainbutton if you use Teradata SQL Assistant.Column names in
selectandgroup by,order by, etc. are separated by comma. There can be no comma after the last column name. This is easy to understand. If you put comma after the last column in a, e.g.,selectclause, thefromkeyword will be treated as the last column and results in syntax error.
Common Syntax Errors¶
Using a comma after the last column or missing a comma after a non-last column in the
selectclause.Miss
thenin acasestatement.:::sql case when condition_1 then v_1 when condition_2 then v_2 ... else v_k endFor
with dataorwith no datawhen creating a table. CREATE TABLE Failed. 3706: Syntax error: expected something between ‘)’ and ‘;’.
SQL Style¶
It is suggested that you write SQL code in the following style.
create table t0 as ( select distinct top 5 * from t1 inner join t2 on condition where condition group by 1 having condition order by 1 ) with data primary index (f1, f2)