SlideShare una empresa de Scribd logo
1 de 3
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.

Más contenido relacionado

Destacado

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 PrimaryiZHERO
 
Feria Internacional de Posgrados
Feria Internacional de PosgradosFeria Internacional de Posgrados
Feria Internacional de PosgradosIbero 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 santiagoLedy Cabrera
 
Great Britain quiz
Great Britain quizGreat Britain quiz
Great Britain quiznata_bond
 
価値をみつけ、つくる人になるWs 慶應大学2013
価値をみつけ、つくる人になるWs 慶應大学2013価値をみつけ、つくる人になるWs 慶應大学2013
価値をみつけ、つくる人になるWs 慶應大学2013Okui Hatsune
 
First conditional
First conditional First conditional
First conditional georginasanz
 
Conditional Clauses (2)
Conditional Clauses (2)Conditional Clauses (2)
Conditional Clauses (2)Marga Alfonso
 

Destacado (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)
 

Último

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Último (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

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.