0

在此处输入图像描述

我在图像中显示的 ER 图中有以下相关的 SQL 查询。

Select count(distinct(tkey)) as fromAustria 
from theses 
where ikey in (select ikey 
               from institutions 
                   right join countries on institutions.cokey = countries.cokey 
               where countries.name = 'Austria'); 

我怎样才能检索到这些信息?

目前隶属于奥地利机构的人发表了多少不同的论文和论文?(返回单数)

我总是有不同的论文,但我怎样才能把不同的论文加到计数中呢?

4

1 回答 1

0

你几乎在那里。如果 'papers' 和 'theses' 表之间没有直接的键关系,则需要通过 'authpapers' 表

Select count(distinct(tkey)) as fromAustria, count(distinct(pkey)) as papers
from theses
Left/Inner/right join Authpapers on authpapers.key = theses.key
Left/Inner/right join papers on  papers.key = authpapers.key
where ikey in (select ikey 
               from institutions 
                   right join countries on institutions.cokey = countries.cokey 
               where countries.name = 'Austria'); 
于 2020-04-24T06:52:08.767 回答