欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

CASE WHEN

系統 1795 0
CASE WHEN case when x = y then a else b end

case when x < y then a when x = y then b else c end

case XYZ when 'foo' then 'moo' else 'bar' end
The following little SQL script demonstrates the use of CASE WHEN. create table test_case_when (
a varchar2(5),
b varchar2(5)
);

insert into test_case_when values ('*','*');
insert into test_case_when values ('+','+');
insert into test_case_when values ('-','-');
insert into test_case_when values ('.','.');

select a,
case
when b = '*' then 'star'
when b = '+' then 'plus'
when b = '-' then 'minus'
else '????'
end
from test_case_when;This select statement produces the following output:A CASEW
----- -----
* star
+ plus
- minus
. ????drop table test_case_when; ORACLE官方文檔說明: CASE
Expressions

There are two types of expressions used in CASE
statements: simple and searched. These expressions correspond to the type of
CASE statement in which they are used. See .


Simple CASE expression

A simple CASE expression selects a result from one or more
alternatives, and returns the result. Although it contains a block that might
stretch over several lines, it really is an expression that forms part of a
larger statement, such as an assignment or a procedure call. The
CASE expression uses a selector,
an expression whose value determines which alternative to return.


A CASE expression has the form illustrated in . The selector ( grade ) is followed
by one or more WHEN clauses, which are checked sequentially. The
value of the selector determines which clause is evaluated. The first
WHEN clause that matches the value of the selector determines the
result value, and subsequent WHEN clauses are not evaluated. If
there are no matches, then the optional ELSE clause is
performed.



Example 2-26 Using the WHEN Clause With a CASE
Statement

DECLARE
grade CHAR(1) := 'B';
appraisal VARCHAR2(20);
BEGIN
appraisal :=
CASE grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
WHEN 'D' THEN 'Fair'
WHEN 'F' THEN 'Poor'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE('Grade ' || grade || ' is ' || appraisal);
END;
/

The optional ELSE clause works similarly to the
ELSE clause in an IF statement. If the value of the
selector is not one of the choices covered by a WHEN clause, the
ELSE clause is executed. If no ELSE clause is provided
and none of the WHEN clauses are matched, the expression returns
NULL .




Searched CASE Expression

A searched CASE expression lets you test different conditions
instead of comparing a single expression to various values. It has the form
shown in .


A searched CASE expression has no selector. Each
WHEN clause contains a search condition that yields a
BOOLEAN value, so you can test different variables or multiple
conditions in a single WHEN clause.



Example 2-27 Using a Search Condition With a CASE
Statement


DECLARE
grade CHAR(1) := 'B';
appraisal VARCHAR2(120);
id NUMBER := 8429862;
attendance NUMBER := 150;
min_days CONSTANT NUMBER := 200;
FUNCTION attends_this_school(id NUMBER) RETURN BOOLEAN IS
BEGIN RETURN TRUE; END;
BEGIN
appraisal :=
CASE
WHEN attends_this_school(id) = FALSE THEN 'N/A - Student not enrolled'
-- Have to test this condition early to detect good students with bad attendance
WHEN grade = 'F' OR attendance < min_days
THEN 'Poor (poor performance or bad attendance)'
WHEN grade = 'A' THEN 'Excellent'
WHEN grade = 'B' THEN 'Very Good'
WHEN grade = 'C' THEN 'Good'
WHEN grade = 'D' THEN 'Fair'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE('Result for student ' || id || ' is ' || appraisal);
END;
/

The search conditions are evaluated sequentially. The BOOLEAN
value of each search condition determines which WHEN clause is
executed. If a search condition yields TRUE , its WHEN
clause is executed. After any WHEN clause is executed, subsequent
search conditions are not evaluated. If none of the search conditions yields
TRUE , the optional ELSE clause is executed. If no
WHEN clause is executed and no ELSE clause is
supplied, the value of the expression is NULL .

CASE WHEN


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: www国产成人免费观看视频,深夜成人网 | 啪啪免费网站 | 999久久久国产精品 成人不卡视频 | 91看片网| 亚洲日本高清成人aⅴ片 | 亚洲精品人成网在线播放影院 | 国产亚洲精品综合在线网址 | 500av导航大全精品 | 国内精品伊人久久久影视 | 成人国产一区二区三区 | 国产免费一区二区三区免费视频 | 日韩在线毛片 | 五月婷久久 | 国产精品久久久久久久久久红粉 | 国产精品午夜电影 | 国产欧美日韩综合精品一区二区 | sm高h视频 | 精品国产99 | 视频毛片| 欧美国产伦久久久久 | 日韩欧美一区在线观看 | 锵锵锵锵锵锵锵锵锵好大好湿软件 | 国产精品一区二区三区99 | 欧美片第一页 | 秋霞理论在线视频 | 久久精品视频5 | 久久天天拍天天爱天天躁 | 亚洲午夜精品国产电影在线观看 | 97在线碰碰观看免费高清 | 男人添女人下面免费网站 | 女人午夜色又刺激黄的视频免费 | 狠狠天天 | 精品久久免费视频 | 国内精品一区二区三区最新 | 久久精品一区二区国产 | 国产精品1区2区3区 国产成人aaa在线视频免费观看 | www.亚洲在线 | 国产精品久久久久久久久久免费看 | 综合一区二区三区 | 欧美一级毛片在线看视频 | 国产精品久久久久无码av |