DECLARE
sala凯管附解校倍快要初拿术ryNUMBER:=20000;
employee_idNUMBER:=36325;
bonus_amountNUMBER;
BEGIN
bonus_amount:=
CASE
WHENsalary>=10000ANDsalary<大粗腊=20000THEN150360问答0
WHENsalary>20000ANDsalary<=40000THEN1000
WHENsalary>40000THEN500
EL布艺SE0
END*10;
DBMS_OUTPUT.PUT_LINE(室皮bonus_amount);
END;
--------------倒析五调---------------言超没州损六云---------------
差斤协且另凳首外一例:
--------日官------------------------------------
CASE
W铁鲁意济HENsalary>=10000ANDsalary<=20000THEN
give_bonus(employee_扬较究苗践id,1500);
WHEN感改记去院编salary>20000ANDsalary<滚滑=40000THEN
give_bon较力球质兵us(employee_id速怕特也到服财,1000);
WHENsalary>40000THEN
give_去否bonus(employee_id,500);
ELSE
give_bonus(emp植律loyee_id,0);
END粉区委紧制行台CASE;
--------联象确双服排------------------------------------
另外一例:
----------------哥----------------------------
selectC_JGDH,
sum(casewhend_qfrq=v_DDATEthenn_qfje-n_hkjeelse0END)asN_YNQF,
sum(casewhend_qfrq<v_DDATEandd_qfrq>=add_months(v_DDATE,-2)thenn_qfje-n_hkjeelse0END)asN_YIJDQF,
sum(casewhend_qfrq<add_months(v_DDATE,-2)andd_qfrq>=add_months(v_DDATE,-5)thenn_q行训功价维阳货措抗fje-n_hkjeelse0END)asN_ERJDQF,
sum(casewhend_qfrq<add_months(v_DDATE,-5)andd_qfrq>=add_months(v_DDATE,-8)thenn_qfje-n_hkjeelse0END)asN_SANJDQF,
sum(casewhend_qfrq<add_months(v_DDATE,-8)andd_qfrq>=add_months(v_DDATE,-11)thenn_qfje-n_hkjeelse0END)asN_SIJDQF,
sum(casewhend_qfrq<add_months(v_DDATE,-11)thenn_qfje-n_hkjeelse0END)asN_YNYSQF,
sum(n_qfje-n_hkje)asN_HJQF,
fromT_DKH_QFHZ
标签:Oracle,Case,When