佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > Oracle case函數(shù)使用介紹

Oracle case函數(shù)使用介紹

熱門標(biāo)簽:鐵路電話系統(tǒng) 服務(wù)外包 AI電銷 呼叫中心市場需求 Linux服務(wù)器 地方門戶網(wǎng)站 網(wǎng)站排名優(yōu)化 百度競價排名

1.創(chuàng)建測試表:

復(fù)制代碼 代碼如下:

DROP SEQUENCE student_sequence;
CREATE SEQUENCE student_sequence  START WITH 10000  INCREMENT BY 1;

DROP TABLE students;
CREATE TABLE students (
  id               NUMBER(5) PRIMARY KEY,
  first_name       VARCHAR2(20),
  last_name        VARCHAR2(20),
  major            VARCHAR2(30),
  current_credits  NUMBER(3),
  grade     varchar2(2));

INSERT INTO students (id, first_name, last_name, major, current_credits,grade)
  VALUES (student_sequence.NEXTVAL, 'Scott', 'Smith', 'Computer Science', 98,null);

INSERT INTO students (id, first_name, last_name, major, current_credits,grade)
  VALUES (student_sequence.NEXTVAL, 'Margaret', 'Mason', 'History', 88,null);

INSERT INTO students (id, first_name, last_name, major, current_credits,grade)
  VALUES (student_sequence.NEXTVAL, 'Joanne', 'Junebug', 'Computer Science', 75,null);

INSERT INTO students (id, first_name, last_name, major, current_credits,grade)
  VALUES (student_sequence.NEXTVAL, 'Manish', 'Murgratroid', 'Economics', 66,null);

commit;

2.查看相應(yīng)數(shù)據(jù)

復(fù)制代碼 代碼如下:

SQL> select * from students;

        ID FIRST_NAME           LAST_NAME            MAJOR                          CURRENT_CREDITS GR
---------- -------------------- -------------------- ------------------------------ --------------- --
     10000 Scott                Smith                Computer Science                            98
     10001 Margaret             Mason                History                                     88
     10002 Joanne               Junebug              Computer Science                            75
     10003 Manish               Murgratroid          Economics                                   66

3.更新語句

復(fù)制代碼 代碼如下:

update students
set grade = (
select grade from
(
select id,
case when current_credits > 90 then 'a'
     when current_credits > 80 then 'b'
     when current_credits > 70 then 'c'
else 'd' end grade
from students
) a
where a.id = students.id
)
/

4.更新后結(jié)果

復(fù)制代碼 代碼如下:

SQL> select * from students;

        ID FIRST_NAME           LAST_NAME            MAJOR                          CURRENT_CREDITS GR
---------- -------------------- -------------------- ------------------------------ --------------- --
     10000 Scott                Smith                Computer Science                            98 a
     10001 Margaret             Mason                History                                     88 b
     10002 Joanne               Junebug              Computer Science                            75 c
     10003 Manish               Murgratroid          Economics                                   66 d

您可能感興趣的文章:
  • oracle case when 語句的用法詳解
  • Oracle數(shù)據(jù)庫的備份與恢復(fù)
  • Oracle誤刪除表數(shù)據(jù)后的數(shù)據(jù)恢復(fù)詳解
  • oracle冷備份恢復(fù)和oracle異機(jī)恢復(fù)使用方法
  • oracle如何恢復(fù)被覆蓋的存儲過程
  • rman恢復(fù)方案和oracle異機(jī)恢復(fù)
  • Oracle數(shù)據(jù)庫數(shù)據(jù)丟失恢復(fù)的幾種方法總結(jié)
  • oracle drop table(表)數(shù)據(jù)恢復(fù)方法
  • oracle數(shù)據(jù)庫創(chuàng)建備份與恢復(fù)腳本整理
  • 一次簡單的Oracle恢復(fù)Case實(shí)戰(zhàn)記錄

標(biāo)簽:湘潭 湖南 衡水 蘭州 銅川 黃山 崇左 仙桃

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle case函數(shù)使用介紹》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    东源县| 谢通门县| 英德市| 大英县| 大庆市| 德庆县| 文昌市| 年辖:市辖区| 正定县| 张家口市| 彰武县| 轮台县| 榆中县| 台东市| 通许县| 阜南县| 平塘县| 多伦县| 宕昌县| 页游| 宝坻区| 平阳县| 南丹县| 宜川县| 塘沽区| 榆树市| 类乌齐县| 康保县| 桐庐县| 石台县| 乐亭县| 饶阳县| 镇康县| 全州县| 宿迁市| 金沙县| 罗平县| 邳州市| 灌云县| 台山市| 沭阳县|