如何在Oracle SQL中创建记录的别名

问题描述

我有一个带有两列滚动和出勤率的表temp

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

我想将此表打印为

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

解决方法

您可以使用case表达式:

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