如何在when case语句中添加子查询。

0 人关注
select distinct 
    a.id, a.number, b.number as school_number, b.id as school_id 
    (select distinct a.id, a.number 
     from faculty a 
     where a.status = 'active') as t1
full outer join
    (select distinct b.id, b.number 
     from staff b 
     where b.status = 'active') as t2 on t1.id = t2.id

我想在SQL Server的多个when case语句中使用上述代码。如何做到这一点?

为此,我创建了一个视图。

create view v_data 
    (select 
         name_loc,
when name_loc like '%city%' or
when name_loc like '%cities%'
then 'Survey'

现在我被卡住了,如何在虚拟表即视图中存在的case语句中使用第一段代码。

我在试图创建视图时得到一个错误。