Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Teradata RDBMS forUNIX SQL Reference - NCR

NCR Teradata RDBMS forUNIX SQL Reference - NCR, 1997. - 913 p.
Download (direct link): teradataforunix1997.pdf
Previous << 1 .. 85 86 87 88 89 90 < 91 > 92 93 94 95 96 97 .. 241 >> Next


This chapter describes the following:

• The SELECT statement

• Simple SELECT statement

• WHERE clause, including subqueries using logical expressions

• FROM list, including derived tables

• WITH clause

• GROUP BY clause

• HAVING clause

• ORDER BY clause

• DISTINCT

This chapter also describes the following query expressions (also referred to as set operator expressions):

• UNION

• INTERSECT

• EXCEPT (MINUS)

Teradata RDBMS for UNIX SQL Reference

7-1
Queries: The SELECT Statement

SELECT

SELECT

Function

The SELECT statement returns row data in the form of a result table.

Syntax

SELECT-SEL-----

DISTINCT— — ALL —

expr-

EAD

aname-

-AS -tname.

FROM-

-joined_table

- tname

AS

aname

INNER

LEFT

Louter-I

JOIN -joinedjable'- ON -sea/c/)_cond -

RIGHT- 1 —FULL—^

CROSS JOIN—single_table -

—( subqueryh---------ã derived_tname -

lASj

-(-L col_name1)-

_ Single Tables

Joined

Tables

Derived j Tables

-WHERE search cond-

lGROUP BY-

C

col_name col_pos ¦ expr-----

!-HAVING-cond-1



ORDER BY

— expr —
-col_name - -ASC-
col_pos DESC

*

7-2

Teradata RDBMS for UNIX SQL Reference
Queries: The SELECT Statement

SELECT

where:

Syntax Element . . . Specifies . . .
DISTINCT that only one row is to be returned from any set of duplicates that might result from a given expr-list. Two rows are considered duplicates only if each value in one is equal to the corresponding value in the other.
ALL that all rows, including duplicates, are to be returned in the results of the expr-list. This is the default value.
* that all columns of all tables referenced in the FROM clause be returned. When qualified by tname, specifies that all columns of only tname are to be returned. View columns are explicitly enumerated when views are defined; therefore, if a table is changed after a view is defined, those changes will not appear if the SELECT * construct is used.
expr an expression. Aggregate and arithmetic operators may be used with expressions.
AS an introduction to the alias name, aname. Optional.
aname a different, temporary name (alias) for the table that is referenced by tname. aname must be used during a self-join operation on the table. aname is also used to name expressions.
tname the name of a table or view. The tname.* in the SELECT list can define the table from which rows are to be returned when two or more tables are referenced in the FROM clause.
FROM an introduction to the names of one or more tables, views, or derived tables from which expr is to be derived. See the section FROM list for detail.

Single Table

This option allows the FROM list to specify single tables.

A FROM list may include a sequence of “single table” references. In this case, an implicit join is created.

This is distinguished from explicit joins where the keyword JOIN is part of the syntax.

tname the name of a single table or view referred to in the FROM list.
AS an introduction to the alias name, aname.
aname a temporary name (alias) for the table that is referred to in the FROM list, tname.
Joined Tables Joined tables options allows the FROM list to specify multiple tables, joined in explicit ways, as described below.
joined_table the name of a joined table.

Teradata RDBMS for UNIX SQL Reference 7-3
Queries: The SELECT Statement

SELECT

Syntax Element . . . Specifies . . .
INNER a join in which qualifying rows from one table are combined with qualifying rows from another table according to some join condition. Types of inner joins include exclusion, merge, nested, product, and row ID. This is the default join type.
OUTER a join in which qualifying rows from one table that do not have matches in the other table, are included in the join result. The rows from the first table are extended with null values.
LEFT OUTER the table that was listed first in the FROM clause. In a LEFT OUTER JOIN, the rows from the left table that are not returned in the result of the inner join of the two tables, are returned in the outer join result, and extended with null values.
RIGHT OUTER the table that was listed second in the FROM clause. In a RIGHT OUTER JOIN, the rows from the right table that are not returned in the result of the inner join of the two tables, are returned in the outer join result, and extended with null values.
FULL OUTER that rows be returned from both tables. In a FULL OUTER JOIN, rows from both tables that have not been returned in the result of the inner join, will be returned in the outer join result, and extended with null values.
JOIN an introduction to the name of the second table to participate in the join.
joined_table the name of the joined table.
ON search_condition one or more conditional expressions that must be satisfied by the result rows. An ON condition clause is required if the FROM clause specifies an outer join.
CROSS JOIN an unconstrained, or Cartesian join; it returns all rows from all tables specified in the FROM clause.
Previous << 1 .. 85 86 87 88 89 90 < 91 > 92 93 94 95 96 97 .. 241 >> Next