/*
Get jnum for projects that has more shipments from
 "local suppliers" (= suppliers that live in the city where 
 the project takes place) than "remote suppliers"
*/

select jnum
from proj J
where 
      (select count(*)            /* # shipments by local suppliers to J */
       from   spj X, supplier S      
       where X.jnum = J.jnum
         and X.snum = S.snum
         and J.city = S.city
       group by X.jnum)
      >
      (select count(*)            /* # shipments by remote suppliers to J */
       from   spj X, supplier S
       where X.jnum = J.jnum
         and X.snum = S.snum
         and J.city != S.city
       group by X.jnum)

