I have a doubt regarding an inner query
Schema:
DEPARTMENT
(deptnum, descrip, instname, deptname, state, postcode)ACADEMIC
(acnum, deptnum*, famname, givename, initials, title)PAPER
(panum, title)AUTHOR
(panum, acnum**)FIELD
(fieldnum, id, title)INTEREST
(fieldnum, acnum**, descrip)
I have the output in this format :
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);
However along with the fields in the select statement of the outer queries, I also want the count(*)
as no_of_papers
in the result set.
I have been breaking my head for quite some time now.