SlideShare a Scribd company logo
Conditional Expressions

Conditional Expressions
Expressions are building blocks for creating conditional expressions that convert a value from one form to
another. Expressions include:
·   CASE (Switch)·      CASE (If)




CASE (Switch)
This form of the CASE statement is also referred to as the CASE(Lookup) form. The value of expr1 is
examined, then the WHEN expressions. If expr1matches any WHEN expression, it assigns the value in the
corresponding THEN expression.

If none of the WHEN expressions match, it assigns the default value specified in the ELSE expression. If
no ELSE expression is specified, the system automatically adds an ELSE NULL.

If expr1 matches an expression in multiple WHEN clauses, only the expression following the first match is
assigned.


Syntax

CASE expr1
  WHEN expr2 THEN expr3
  {WHEN expr... THEN expr...}
  ELSE expr
END
Where:

CASE starts the CASE statement. Must be followed by an expression and one or
more WHEN and THEN statements, an optional ELSE statement, and the END keyword.

WHEN specifies the condition to be satisfied.

THEN specifies the value to assign if the corresponding WHEN expression is satisfied.

ELSE specifies the value to assign if none of the WHEN conditions are satisfied. If omitted, ELSE NULL is
assumed.

END ends the CASE statement.

Example



CASE "TableHeading"."Column Name"
WHEN 'Col_Val1' THEN 'Val1'
WHEN 'Col_Val2' THEN 'Val2'
WHEN 'Col_Val3' THEN 'Val3'
ELSE "TableHeading"."Column Name"
END

In this example, the WHEN statements must reflect a strict equality.



CASE (If)
This form of the CASE statement evaluates each WHEN condition and if satisfied, assigns the value in the
corresponding THEN expression.

If none of the WHEN conditions are satisfied, it assigns the default value specified in the ELSE expression. If
no ELSE expression is specified, the system automatically adds an ELSE NULL.




Syntax



CASE
  WHEN request_condition1 THEN expr1
  {WHEN request_condition2 THEN expr2}
  {WHEN request_condition... THEN expr...}
  ELSE expr
END
Where:

CASE starts the CASE statement. Must be followed by one or more WHEN and THEN statements, an
optional ELSE statement, and the END keyword.

WHEN specifies the condition to be satisfied.

THEN specifies the value to assign if the corresponding WHEN expression is satisfied.

ELSE specifies the value to assign if none of the WHEN conditions are satisfied. If omitted, ELSE NULL is
assumed.

END ends the CASE statement.

Example



CASE
WHEN ("TableHeading"."ColumnName1"='Collaboration' AND "TableHeading"."ColumnName"='Value1')
THEN 'Val1'
WHEN ("TableHeading"."ColumnName1"='Collaboration' AND
"TableHeading1"."ColumnName2"='Value2') THEN 'Val2'
WHEN "TableHeading"."Column Name"='Value3' THEN 'Val3'
ELSE "TableHeading"."Column Name"
END

Note :
Unlike the Switch form of the CASE statement, the WHEN statements in the If form allow comparison operators.
In a CASE statement, AND has precedence over OR.

More Related Content

PPT
Conditional 1
PPT
Conditional 1 ppt
PPT
DOCX
Slideshare
PDF
Embedded sw engineer automotive
PDF
Caratula
PPTX
Jornada escolar de prevención y mitigación del dengue septiembre 2015
PDF
Kazakhstan regulatory laws 134
Conditional 1
Conditional 1 ppt
Slideshare
Embedded sw engineer automotive
Caratula
Jornada escolar de prevención y mitigación del dengue septiembre 2015
Kazakhstan regulatory laws 134

Viewers also liked (15)

DOCX
Logo.jpeg
PPT
SOCIAL MEDIA and NEWS ENGAGEMENT: GO BEYOND THE TWEET
PDF
iZ HERO Parents Training @ Anglo-Chinese School Primary
PDF
Requirement engineer es
ODP
PROYECTO
PDF
Feria Internacional de Posgrados
PDF
Upgrade Your Apps With Yammer
DOCX
Todas Las Fechas Celebradas en República Dominicana. Durante el Año Organizad...
PPTX
Batalla 30 de Marzo santiago
PPT
Great Britain quiz
PDF
価値をみつけ、つくる人になるWs 慶應大学2013
PPTX
First conditional
PPT
First Conditional
PPT
Conditional 1
PPT
Conditional Clauses (2)
Logo.jpeg
SOCIAL MEDIA and NEWS ENGAGEMENT: GO BEYOND THE TWEET
iZ HERO Parents Training @ Anglo-Chinese School Primary
Requirement engineer es
PROYECTO
Feria Internacional de Posgrados
Upgrade Your Apps With Yammer
Todas Las Fechas Celebradas en República Dominicana. Durante el Año Organizad...
Batalla 30 de Marzo santiago
Great Britain quiz
価値をみつけ、つくる人になるWs 慶應大学2013
First conditional
First Conditional
Conditional 1
Conditional Clauses (2)
Ad

Recently uploaded (20)

PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Trump Administration's workforce development strategy
PDF
RMMM.pdf make it easy to upload and study
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Computing-Curriculum for Schools in Ghana
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
A systematic review of self-coping strategies used by university students to ...
Cell Types and Its function , kingdom of life
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Final Presentation General Medicine 03-08-2024.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Trump Administration's workforce development strategy
RMMM.pdf make it easy to upload and study
STATICS OF THE RIGID BODIES Hibbelers.pdf
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Weekly quiz Compilation Jan -July 25.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Orientation - ARALprogram of Deped to the Parents.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Computing-Curriculum for Schools in Ghana
O5-L3 Freight Transport Ops (International) V1.pdf
Microbial diseases, their pathogenesis and prophylaxis
Ad

Conditional expressions

  • 1. Conditional Expressions Conditional Expressions Expressions are building blocks for creating conditional expressions that convert a value from one form to another. Expressions include: · CASE (Switch)· CASE (If) CASE (Switch) This form of the CASE statement is also referred to as the CASE(Lookup) form. The value of expr1 is examined, then the WHEN expressions. If expr1matches any WHEN expression, it assigns the value in the corresponding THEN expression. If none of the WHEN expressions match, it assigns the default value specified in the ELSE expression. If no ELSE expression is specified, the system automatically adds an ELSE NULL. If expr1 matches an expression in multiple WHEN clauses, only the expression following the first match is assigned. Syntax CASE expr1 WHEN expr2 THEN expr3 {WHEN expr... THEN expr...} ELSE expr END Where: CASE starts the CASE statement. Must be followed by an expression and one or more WHEN and THEN statements, an optional ELSE statement, and the END keyword. WHEN specifies the condition to be satisfied. THEN specifies the value to assign if the corresponding WHEN expression is satisfied. ELSE specifies the value to assign if none of the WHEN conditions are satisfied. If omitted, ELSE NULL is assumed. END ends the CASE statement. Example CASE "TableHeading"."Column Name" WHEN 'Col_Val1' THEN 'Val1'
  • 2. WHEN 'Col_Val2' THEN 'Val2' WHEN 'Col_Val3' THEN 'Val3' ELSE "TableHeading"."Column Name" END In this example, the WHEN statements must reflect a strict equality. CASE (If) This form of the CASE statement evaluates each WHEN condition and if satisfied, assigns the value in the corresponding THEN expression. If none of the WHEN conditions are satisfied, it assigns the default value specified in the ELSE expression. If no ELSE expression is specified, the system automatically adds an ELSE NULL. Syntax CASE WHEN request_condition1 THEN expr1 {WHEN request_condition2 THEN expr2} {WHEN request_condition... THEN expr...} ELSE expr END Where: CASE starts the CASE statement. Must be followed by one or more WHEN and THEN statements, an optional ELSE statement, and the END keyword. WHEN specifies the condition to be satisfied. THEN specifies the value to assign if the corresponding WHEN expression is satisfied. ELSE specifies the value to assign if none of the WHEN conditions are satisfied. If omitted, ELSE NULL is assumed. END ends the CASE statement. Example CASE WHEN ("TableHeading"."ColumnName1"='Collaboration' AND "TableHeading"."ColumnName"='Value1') THEN 'Val1' WHEN ("TableHeading"."ColumnName1"='Collaboration' AND "TableHeading1"."ColumnName2"='Value2') THEN 'Val2' WHEN "TableHeading"."Column Name"='Value3' THEN 'Val3' ELSE "TableHeading"."Column Name"
  • 3. END Note : Unlike the Switch form of the CASE statement, the WHEN statements in the If form allow comparison operators. In a CASE statement, AND has precedence over OR.