SlideShare uma empresa 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.

Mais conteúdo relacionado

Destaque

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
 

Destaque (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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 

Ú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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 

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.