Case has two formats. Simple case function and case search function.--Simple case function when ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when
Case has two formats. Simple case function and case search function.--Simple case function when ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when
--Simple case function when ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other ' end--case search function case when sex = ' 1 ' Then ' man ' when Sex = ' 2 ' Then ' women ' else ' other ' ENDIn both of these ways,
Back in the evening, the classmate said the interview encountered a SQL interview topic, did a bit of their own, summary summary.The topics are as follows: The following is a product data sheet (Product ID, color col, num), each of which is
Reprinted from http://lj.soft.blog.163.com/blog/static/7940248120109215191358/Case has two formats. Simple case function and case search function.--Simple case function when ' 1 ' then ' Male ' when ' 2 ' then ' women ' else ' other '
SQL statement case when then else end returns a qualified value, sqlcase
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' other 'ends -- Case
Use of case, simple case functionA simple case expression that uses an expression to determine the return value.
Grammar:
Case Search_expression
When Expression1 THEN RESULT1
When Expression2 THEN result2
...
When Expressionn THEN Resultn
ELSE
CASE has two formats:The simple CASE function compares an expression with a group of simple expressions to determine the result.The CASE search function calculates a group of Boolean expressions to determine the result.Both formats support the
1. Standard SQL specificationOne, single IF1, if A= ... Then.........end if;2, if a= ... then......else....end if; two, more IfIf a=. Then......elsif a=. Then....end if; The middle here is "elsif", not else IF. Special attention is needed
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.