15.00 - BEGIN - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

BEGIN

Purpose  

Returns the beginning bound of a Period expression or a derived period.

Syntax  

where:

 

Syntax element...

Specifies...

period_expression

any expression that evaluates to a Period data type.

derived_period

any expression that evaluates to a derived period.

Return Value

The result data type of the BEGIN function is same as the element type of the Period expression or the data type of the begin column if the argument is a derived period column. If the argument is NULL, the result is NULL.

Format and Title

The format is the default format for the element type of the Period expression or the format of the begin column if the argument is a derived period column.

Error Conditions

If the argument does not have a Period data type, an error is reported.

Example  

BEGIN returns the beginning bound of a Period data type.

   SELECT * FROM employee WHERE BEGIN(period1) = DATE '2004-06-19';

Assume the query is executed on the following employee table where period1 is a PERIOD(DATE) column:

   ename   dept          period1
   -----   -----------   ----------------------------
   Jones   Sales         ('2004-01-02', '2004-01-05')
   Adams   Marketing     ('2004-06-19', '2005-02-09')
   Mary    Development   ('2004-06-19', '2005-01-05')
   Simon   Sales         ('2004-06-22', '2005-01-07')

The result is:

   ename   dept          period1
   -----   -----------   ----------------------------
   Adams   Marketing     ('2004-06-19', '2005-02-09')
   Mary    Development   ('2004-06-19', '2005-01-05')

Example  

BEGIN returns the beginning bound (jdbegin) of a derived period called jobduration created using the following SQL statement:

CREATE TABLE employee(id INTEGER,
                      name VARCHAR(50),
                      jdbegin DATE NOT NULL FORMAT 'YYYY-MM-DD',
                      jdend   DATE NOT NULL FORMAT 'YYYY-MM-DD',
                      PERIOD FOR jobduration(jdbegin,jdend)
  )PRIMARY INDEX(id);

The following SQL statements:

INSERT INTO employee(1025,'John',DATE'2011-01-02',DATE'2012-05-02');
SELECT BEGIN (jobduration) FROM employee;

returns:

     jdbegin
  __________
  2011-01-02