我对内部查询有疑问
架构:
DEPARTMENT
( deptnum , 描述, instname, deptname, state, postcode)ACADEMIC
(acnum、deptnum*、famname、givenname、首字母、头衔)PAPER
(全景,标题)AUTHOR
( panum , acnum **)FIELD
(字段编号,ID,标题)INTEREST
( fieldnum , acnum **, 描述)
我有这种格式的输出:
select
acnum, title, givename, famname
from
academic a
where
a.acnum in (select count(*) as no_of_papers, acnum
from author auth
join paper p on auth.panum = p.panum
group by acnum
having count(*) < 20)
union
select
acnum, title, givename, famname
from
academic a
where
a.acnum not in (select count(*) as no_of_papers, acnum
from author auth
join paper p on auth.panum = p.panum
group by acnum);
但是,除了外部查询的 select 语句中的字段外,我还希望结果集中的count(*)
as no_of_papers
。
我已经打破了我的头很长一段时间了。