17.10 - Example: CASE_N Partitioning Expression Using the END Bound Function - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1144-171K
Language
English (United States)

This example creates a table whose primary index is partitioned using a CASE_N expression and END bound functions.

     CREATE TABLE orders (
       o_orderkey      INTEGER NOT NULL,
       o_custkey       INTEGER,
       o_orderperiod   PERIOD(DATE) NOT NULL
       o_orderpriority CHARACTER(21),
       o_comment       VARCHAR(79))
     PRIMARY INDEX (o_orderkey)
     PARTITION BY CASE_N (END(o_orderperiod) <= DATE '2010-03-31',/*Q1*/
                          END(o_orderperiod) <= DATE '2010-06-30',/*Q2*/
                          END(o_orderperiod) <= DATE '2010-09-30',/*Q3*/
                          END(o_orderperiod) <= DATE '2010-12-31' /*Q4*/
                         );