SQL:我可以根据值在表行旁边显示注释吗?

SQL:我可以根据值在表行旁边显示注释吗?,sql,oracle,Sql,Oracle,比如说,我有一张员工桌 员工编号、开始日期、员工姓名、性别、员工单位 其中单位为1,2,3 我想显示一个附加列,该列不在表中,其注释取决于表中的值 也就是说,如果unit='1',这意味着他们为巴黎工作,我想展示这一点;若该员工在2016年开始工作,那个么他是一名新员工,我想在下面的信息示例中显示您需要的案例。例如: /* build a test case */ with test(n, y) as ( select 1, 2016 from dual union all se

比如说,我有一张员工桌 员工编号、开始日期、员工姓名、性别、员工单位 其中单位为1,2,3

我想显示一个附加列,该列不在表中,其注释取决于表中的值

也就是说,如果unit='1',这意味着他们为巴黎工作,我想展示这一点;若该员工在2016年开始工作,那个么他是一名新员工,我想在下面的信息示例中显示您需要的案例。例如:

/* build a test case */
with test(n, y) as (
    select 1, 2016 from dual union all
    select 2, 2000 from dual
)
/* the query */
select n,
       case
        when n = 1 then 'comment when n=1'
        when n = 2 then 'comment when n=2'
       end
       || ' and ' ||
       case
        when y > 2010 then 'year greater than 2010'
        else 'year <= 2010'
       end as comm
from test;  
给出:

         N COMM
---------- -------------------------------------------
         1 comment when n=1 and year greater than 2010
         2 comment when n=2 and year <= 2010
你需要一个箱子。例如:

/* build a test case */
with test(n, y) as (
    select 1, 2016 from dual union all
    select 2, 2000 from dual
)
/* the query */
select n,
       case
        when n = 1 then 'comment when n=1'
        when n = 2 then 'comment when n=2'
       end
       || ' and ' ||
       case
        when y > 2010 then 'year greater than 2010'
        else 'year <= 2010'
       end as comm
from test;  
给出:

         N COMM
---------- -------------------------------------------
         1 comment when n=1 and year greater than 2010
         2 comment when n=2 and year <= 2010