This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
dev:sql:functions:case [2009/12/04 22:25] tdo |
dev:sql:functions:case [2012/10/26 14:28] (current) |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| <html><div align="center"><span style="color:red">DRAFT</span></div></html> | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
| ====== Omnidex SQL Function: CASE ====== | ====== Omnidex SQL Function: CASE ====== | ||
| + | {{page>:sql_bar&nofooter&noeditbtn}} | ||
| ===== Description ===== | ===== Description ===== | ||
| The CASE function handles simple IF - THEN - ELSE logic at a select-item level. The WHEN conditions are evaluated in order until a condition proves TRUE, at which point the THEN expression is executed. All of the THEN expressions in a CASE statement must be of the same data type: numeric, character, or date. | The CASE function handles simple IF - THEN - ELSE logic at a select-item level. The WHEN conditions are evaluated in order until a condition proves TRUE, at which point the THEN expression is executed. All of the THEN expressions in a CASE statement must be of the same data type: numeric, character, or date. | ||
| Line 38: | Line 39: | ||
| END | END | ||
| </code> | </code> | ||
| - | + | ==== Example 3 Select Statement with Conditional Expression ==== | |
| - | ==== Example 3 ==== | + | |
| <code SQL> | <code SQL> | ||
| Line 56: | Line 56: | ||
| order by state | order by state | ||
| </code> | </code> | ||
| - | ==== Example 4 ==== | + | ==== Example 4 Select Statement with Scalar Expression ==== |
| <code SQL> | <code SQL> | ||
| select company, contact, | select company, contact, | ||