0

enter image description here

I have following SQL Query related at the ER-Diagram shown in the image.

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'); 

How can I retrieve this information?

How many distinct theses and papers did persons currently affiliated with Austrian institutions publish? (return single count)

I always have the distinct theses, but how can i add to the count the distinct papers?

1 Answers1

0

You're pretty much there. If there is no direct key relationship between the 'papers' and 'theses' tables, you will need to go through the 'authpapers' table

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'); 
KMoe
  • 125
  • 10