首页 > 解决方案 > 如何在oracle sql中创建记录的别名

问题描述

我有一个带有 2 列滚动和出勤率的表临时表

roll   attendance 
--------------
1       A
2       P
3       NA

我想将此表打印为

roll   attendance 
--------------
1       Absent
2       Present
3       Not applicable

标签: sqlstringoracleselectaliases

解决方案


您可以使用case表达式:

select roll, 
    case attendance
        when 'A'  then 'Absent'
        when 'P'  then 'Present'
        when 'NA' then 'Not applicable'
    end as attendance
from mytable

推荐阅读