这里是架构的一个画面:http://i.stack.imgur.com/yr26g.png如何使用减或者不存在
我想创建一个查询,以找到出版物的数量最多时ICDE,谁没有在SIGMOD出版的作者。
我认为我是在正确的轨道上得到作者的最高出版物数量ICDE:
select AUTHOR.NAME, aid, count(PUBLICATION.id)
from PUBLICATION, AUTHORPUBLICATION, CONFERENCE, AUTHOR
where aid=AUTHOR.id and pid=PUBLICATION.id and cid=CONFERENCE.id and CONFERENCE.name='ICDE'
group by AUTHOR.name, aid order by count(PUBLICATION.id) desc;
,但不知道如何形成的查询,以便它不包括已发表在SIGMOD作者
中我已经试过的东西:
with aut(n,a,i) as
((select AUTHOR.NAME, aid, count(PUBLICATION.id) as cnt
from PUBLICATION, AUTHORPUBLICATION, CONFERENCE, AUTHOR
where aid=AUTHOR.id and pid=PUBLICATION.id and cid=CONFERENCE.id and CONFERENCE.name='ICDE'
group by AUTHOR.NAME, aid)
minus
(select AUTHOR.NAME, aid, count(PUBLICATION.id) as cnt
from PUBLICATION, AUTHORPUBLICATION, CONFERENCE, AUTHOR
where aid=AUTHOR.id and pid=PUBLICATION.id and cid=CONFERENCE.id and CONFERENCE.name='SIGMOD'
group by AUTHOR.NAME, aid))
select n,a,i from aut order by i desc;
,但它似乎并没有在所有的工作。我有一个列表 author, id, paper_id
或 list of author, id, count(paper)
(我试了两种方法),因为纸ID我认为我有一个不相交的设置,不能得到这个工作。已经花了3小时了:(
我也尝试过的东西摆脱纸张的id:
with aut(n,a) as
((select AUTHOR.NAME, aid
from PUBLICATION, AUTHORPUBLICATION, CONFERENCE, AUTHOR
where aid=AUTHOR.id and pid=PUBLICATION.id and cid=CONFERENCE.id and CONFERENCE.name='ICDE'
order by count(PUBLICATION.id) desc)
minus
(select AUTHOR.NAME, aid
from PUBLICATION, AUTHORPUBLICATION, CONFERENCE, AUTHOR
where aid=AUTHOR.id and pid=PUBLICATION.id and cid=CONFERENCE.id and CONFERENCE.name='SIGMOD'
order by count(PUBLICATION.id) desc))
select n,a from aut;
,但它说我缺少一个括号我不
我的首选项是不使用减号命令。您可以将join加入到一个子查询中,该子查询返回已排除的ID列表和过滤器,其中subquery.id为null,以仅获取列表中未包含的列表.... harsh psuedo code:select * from query left join(select ID's不包括在)id = id其中subquery.id为空。 – Twelfth 2014-09-24 22:50:43