Netezza / PureData – Case Statement Example

Netezza PureData Case statement Function example
Netezza PureData Case Function

The Case Statement is one which I occasionally use within Netezza/PureData SQL and Stored Procedures.  Basically, the Case Function provides an ‘IF-THEN-ELSE’ decision capability.  This ‘IF-THEN-ELSE’ capability allows the evaluation conditions and return a value when the first condition is met and/ or else break out logic if the condition or conditions are not met.

Case Function Language Structure

·       Case Function Basic Structure


WHEN <search-condition-1> THEN <result-1>

WHEN <search-condition-2> THEN <result-2>

WHEN <search-condition-n> THEN <result-n>

ELSE <default-result>


·       Case Function Simple Structure


WHEN <search-condition-1> THEN <result-1>

ELSE <default-result>


Case Function Embedded in SQL Select Example

Case Function Embedded In SQL Select Statement
Case Function Embedded In SQL Select Statement

SQL Used in Embedded Example


now() as “Time”,

current_date as “Today”,



when (DATE_PART(‘HOUR’,NOW())>12 )

THEN date(current_date +  cast(‘1 days’ as interval))

ELSE  current_date


From ADMIN._v_dual;

Related References

IBM Knowledge Center, PureData System for Analytics, Version 7.2.1

IBM Netezza database user documentation, Netezza SQL basics, Functions, and operators, Functions

One thought on “Netezza / PureData – Case Statement Example

Comments are closed.