-1

这是我的脚本。

select jt.exempt_status as ExemptStatus, COUNT(*) as ExemptCount
from employee as e
join job_title as jt
    on e.job_title = jt.job_title
group by jt.exempt_status

执行时显示

ExemptStatus     ExemptCount
-----------------------------    
E                2
N                5

我需要它在不更改 jt.exempt_status 字段中的值的情况下显示。

ExemptStatus     ExemptCount
-----------------------------    
Exempt           2
Non-Exempt       5
4

1 回答 1

2

CASE选择它们时,您可以使用表达式来格式化您的值:

select CASE jt.exempt_status 
    WHEN 'E' THEN 'Exempt'
    WHEN 'N' THEN 'Non-Exempt'
    END 
    as ExemptStatus, COUNT(*) as ExemptCount
from employee as e
join job_title as jt
    on e.job_title = jt.job_title
group by jt.exempt_status 
于 2012-09-27T17:37:51.237 回答