15.10 - WHERE search_condition - Teradata Database

Teradata Database SQL Data Definition Language Syntax and Examples

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1144-151K

A conditional search expression that must be satisfied by the row set returned by the specified SELECT request.

You cannot specify a SAMPLE clause within a subquery predicate within a WHERE clause.

Example: Creating a View that Defines a Self-Join with a Table

The following request creates a view that allows a personnel executive to keep track of employees who have more experience on the job than their supervisors. This request defines a self-join of the employee table. The correlation names workers and managers, created in the FROM clause, see the two temporary tables participating in the self-join.

    CREATE VIEW emp_info (workername,workeryrsexp,department, 
                          managername,manageryrsexp) AS
     SELECT workers.name, workers.yrsexp, workers.deptno, 
            managers.name, managers.yrsexp
     FROM employee AS workers, employee AS managers 
     WHERE workers.deptno = managers.deptno 
     AND managers.jobtitle IN ('Manager', 'Vice Pres') 
     AND workers.yrsexp > managers.yrsexp;

Example: Invoking an SQL UDF Within a View Definition

This example invokes the SQL UDF value_expression in the select list of the definition of the view named v1.

     CREATE VIEW v1 (a, b, c) 
       AS SELECT a1, test.value_expression(3,4), c1
          FROM t1 
          WHERE a1 > b1;

The next example invokes the SQL UDF value_expression in the WHERE clause of the view named v2.

     CREATE VIEW v2 (a, b, c) 
       AS SELECT a1, b1, c1 
          FROM t1
          WHERE test.value_expression(b1, c1) > 10;