--Q1
select e.name
    from workson w, project p, employee e
    where w.enum=e.enum
      and w.pnum=p.pnum
      and p.dnum<>e.dnum;
--Q2
select e.name, sum(w.hours), sum(w.hours)/count(distinc w.pnum)
    from worksno w, employee e
    where w.enum=e.enum
    group by e.name
    order by 2,3;
--Q3
select d.dname
    from department d, employee m,
         (select dnum, sum(salary) sum_salary from employee group by dnum) s
    where d.dnum=s.dnum and d.mgrenum=m.enum
      and m.salary>s.salary*0.4;