PLSQL中,select case..when.. then..什么意思?怎么用

 时间:2026-04-25 11:15:27

case when ... then .. when .. then ... end

这种表达式,是sql的不同条件分支结果。

举例如下,

1、创建数据表,create table test_student(stu_id number, class_id number);

PLSQL中,select case..when.. then..什么意思?怎么用

2、插入测试数据,

insert into test_student values(1,1001);

insert into test_student values(2,1001);

insert into test_student values(3,1002);

insert into test_student values(4,1003);

insert into test_student values(5,1003);

insert into test_student values(6,1003);

PLSQL中,select case..when.. then..什么意思?怎么用

3、查询表中数据,select * from test_student ,

PLSQL中,select case..when.. then..什么意思?怎么用

4、编写case when 表达式,将class_id翻译为中文名称,sql如下,

select t.*,

       case

         when class_id = 1001 then

          '语文'

         when class_id = 1002 then

          '数学'

         when class_id = 1003 then

          '英语'

       end as class_name

  from test_student t;

PLSQL中,select case..when.. then..什么意思?怎么用

  • VBA如何隐藏工作表?
  • Navicat Premium16如何设置使用自动完成代码
  • java.lang.classcastexception怎么解决
  • EXCEL“文件已损坏,无法打开”如何拯救数据?
  • 如何设置el-tree内容自定义
  • 热门搜索
    上海大学怎么样 ps索引怎么解锁 怎么用钱折爱心 微信小号怎么弄 微信公众号怎么登陆 弹吉他手指疼怎么办 怎么制作网页 淘宝公益宝贝怎么设置 钢筋图纸怎么看 三线表怎么做