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

Viewers also liked

Logo.jpeg
Logo.jpegLogo.jpeg
Logo.jpeg
clubserinus
 
iZ HERO Parents Training @ Anglo-Chinese School Primary
iZ HERO Parents Training @ Anglo-Chinese School PrimaryiZ HERO Parents Training @ Anglo-Chinese School Primary
iZ HERO Parents Training @ Anglo-Chinese School Primary
iZHERO
 
Requirement engineer es
Requirement engineer esRequirement engineer es
Requirement engineer es
Manuel Teunissen
 
PROYECTO
PROYECTOPROYECTO
PROYECTO
JUANTENEMEA
 
Feria Internacional de Posgrados
Feria Internacional de PosgradosFeria Internacional de Posgrados
Feria Internacional de Posgrados
Ibero Posgrados
 
Upgrade Your Apps With Yammer
Upgrade Your Apps With Yammer Upgrade Your Apps With Yammer
Upgrade Your Apps With Yammer
Yammer
 
Todas Las Fechas Celebradas en República Dominicana. Durante el Año Organizad...
Todas Las Fechas Celebradas en República Dominicana. Durante el Año Organizad...Todas Las Fechas Celebradas en República Dominicana. Durante el Año Organizad...
Todas Las Fechas Celebradas en República Dominicana. Durante el Año Organizad...
Ledy Cabrera
 
Batalla 30 de Marzo santiago
Batalla 30 de Marzo santiagoBatalla 30 de Marzo santiago
Batalla 30 de Marzo santiago
Ledy Cabrera
 
Great Britain quiz
Great Britain quizGreat Britain quiz
Great Britain quiz
nata_bond
 
価値をみつけ、つくる人になるWs 慶應大学2013
価値をみつけ、つくる人になるWs 慶應大学2013価値をみつけ、つくる人になるWs 慶應大学2013
価値をみつけ、つくる人になるWs 慶應大学2013
Okui Hatsune
 
First conditional
First conditional First conditional
First conditional
georginasanz
 
First Conditional
First Conditional  First Conditional
First Conditional
Helen Collins
 
Conditional 1
Conditional 1Conditional 1
Conditional 1
Danitza Lazcano Flores
 
Conditional Clauses (2)
Conditional Clauses (2)Conditional Clauses (2)
Conditional Clauses (2)
Marga Alfonso
 

Viewers also liked (15)

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

Recently uploaded

Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptxFresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
SriSurya50
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Reflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPointReflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPoint
amberjdewit93
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 

Recently uploaded (20)

Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptxFresher’s Quiz 2023 at GMC Nizamabad.pptx
Fresher’s Quiz 2023 at GMC Nizamabad.pptx
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Reflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPointReflective and Evaluative Practice PowerPoint
Reflective and Evaluative Practice PowerPoint
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 

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.