如何用英语解释?

时间:2019-05-26 11:55:50

标签: sql

select S.acnum
from interest S 
where upper(S.descrip) like '%LOGIC%'
    and exists (select fieldnum
                    from interest
                    where acnum = S.acnum 
                        and upper(descrip) not like '%LOGIC%');

我需要用英语描述外部查询。我该怎么办?

1 个答案:

答案 0 :(得分:1)

我更愿意这样写:

select i.acnum
from interest i
group by i.acnum
having sum(case when upper(i.descrip) like '%LOGIC%' then 1 else 0 end) > 0 and
       sum(case when upper(i.descrip) not like '%LOGIC%' then 1 else 0 end) > 0;

此版本不会产生重复的值。就是说,要获取所有具有至少一条记录的所有acnum,其中descrip包含LOGIC,而另一条记录不包含LOGIC