The use of case when (turn)--Simple Case functionA simple case expression that uses an expression to determine the return value.
Grammar:
The code is as follows
Copy Code
Case Search_expressionWhen Expression1 THEN
Case has two formats. Simple case function and case search function.--Simple Case functionCase SexWhen' 1 'then man ' when ' 2 ' then female ' else ' then ' man ' when sex = ' 2 ' then female ' end In both of these ways, the
1.CHECK constrained SQL CHECK constraintsA CHECK constraint is used to limit the range of values in a column.If you define a CHECK constraint on a single column, the column only allows a specific value.If a CHECK constraint is defined on a table,
Case has two formats. Simple case function and case search function.--Simple case function Sexwhen ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when sex = ' 2 ' Then '
Case has two formats. Simple case function and case search function.--Simple case function CaseSex when ' 1 ' Then ' man ' when ' 2 ' Then ' Woman 'ELSE 'Other ' END--case search Function Case whenSex =' 1 ' Then ' man ' whenSex =' 2 ' Then '
Case has two formats. Simple case function and case search function.--Simple case function Sexwhen ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when sex = ' 2 ' Then '
Case has two formats. Simple Case functions and Case search functions.
Case has two formats. Simple Case functions and Case search functions.
The Code is as follows:
-- Simple Case Function
CASE sex
WHEN '1' THEN 'male'
WHEN '2' THEN 'female'
ELSE '
Case has two formats. Simple case functions and case search functions.
-- Simple case Function Case Sex When '1' Then Male' When '2' Then Female' Else 'Others' End -- Case search function Case When Sex ='1' Then Male'
Case has two formats. Simple case functions and case search functions.
-- Simple case Function Case Sex When '1' Then Male' When '2' Then Female' Else 'Others' End -- Case search function Case When Sex ='1' Then Male'
Case has two formats. Simple case function and case search function.--Simple case function Sexwhen ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when sex = ' 2 ' Then '
We all know the usage of Casewhen. Once a certain WHEN is satisfied, the data will exit the CASEWHEN instead of considering other cases, this article introduces the usage of casewhen in detail and gives an example.
We all know the usage of Case when.
Case when usage, simple Case FunctionUse a simple CASE expression to determine the return value.
Syntax:
CASE search_expression
WHEN expression1 THEN result1
WHEN expression2 THEN result2
...
WHEN expressionN THEN resultN
ELSE default_result
Search
Copy codeThe Code is as follows:-- Simple Case FunctionCASE sexWHEN '1' THEN 'male'WHEN '2' THEN 'female'ELSE 'others' END-- Case search functionCase when sex = '1' THEN 'male'WHEN sex = '2' THEN 'female'ELSE 'others' END These two methods can
Case has two formats. Simple case functions and case search functions.-- Simple case FunctionCase sexWhen '1' then 'male'When '2' then 'female'Else 'others' end-- Case search functionCase when sex = '1' then 'male'When sex = '2' then 'female'Else
Case has two formats. Simple Case functions and Case search functions.
Case has two formats. Simple Case functions and Case search functions.
-- Simple Case FunctionCASE sexWHEN '1' THEN 'male'WHEN '2' THEN 'female'ELSE 'others' END-- Case search
CaseWhen condition 1THEN Results 1When condition 2THEN results 2When condition 3THEN results 3When condition 4THEN results 4.........When condition Nthen result nelse result XENDCase has two formats. Simple case function and case search
CaseWhen condition 1 then result 1When condition 2 then result 2When condition 3 then result 3When condition 4 then result 4.........When condition n then result nELSE result XENDCase has two formats. Simple case function and case search
The worst place to case When--then--else--end should be that it is used both in normal fields and in aggregate functions.Original: http://blog.itpub.net/26451903/viewspace-733526Case has two formats. Simple case function and case search
Case has two formats. Simple case function and case search function.--Simple Case functionCase Sexwhen ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when sex = ' 2 ' Then '
Source: http://blog.csdn.net/IBM_hoojo/archive/2010/04/30/5546868.aspx
Case has two formats. Simple case functions and case search functions.-- Simple case FunctionCase sexWhen '1' then 'male'When '2' then 'female'Else 'others' end-- Case search
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.