User Tools

Site Tools


Sidebar

**HPL/SQL is included to Apache Hive since version 2.0** * [[home|Home]]\\ * [[why|Why HPL/SQL]]\\ * [[features|Key Features]]\\ * [[start|Get Started]]\\ * [[doc|HPL/SQL Reference]]\\ * [[download|Download]]\\ * [[new|What's New]]\\ * [[about|About]]

case

====== CASE Expression - PL/HQL Reference ====== CASE expression allows you to implement IF-THEN-ELSE logic in expressions. **Syntax:** Simple CASE expression: <code language=sql> CASE expr WHEN expr THEN expr ... [ELSE expr] END </code> Searched CASE expression: <code language=sql> CASE WHEN boolean_expr THEN expr ... [ELSE expr] END </code> **Notes**: * NULL is returned if none of the WHEN expressions is matched and ELSE clause is not specified **Examples**: Simple CASE expression: <code language=sql> CASE state WHEN 'AZ' THEN 'Arizona' WHEN 'CA' THEN 'California' ELSE 'N/A' END </code> Searched CASE expression: <code language=sql> CASE WHEN state = 'AZ' THEN 'Arizona' WHEN state = 'CA' THEN 'California' ELSE 'N/A' END </code> **Compatibility:** Oracle, IBM DB2, SQL Server, Teradata, MySQL, PostgreSQL and Netezza. **Version**: PL/HQL 0.01 See also: * [[decode|DECODE Function]]