I have 3 tables relating to Submission and Researcher.
Submission table:
SubmissionID, Type, Title, Status, Comment, CapturedOnRIMS, NumberOfAuthors, NumberOfWitsAuthors, TotalPages, PagesInPreamble, PagesInText, NumberOfChapters, Location, PublicationID, CESMID, SubmissionDate
Researcher table:
ResearcherID, FirstName, Surname, RegistrationDate, QualificationType, JobName, Availability, SchoolID
ResearcherSubmission (relational table):
SubmissionID, ResearcherID
I am trying to create a query that display a count of the total number of submissions per researcher. A researcher can have many submissions, and a submission can be done by many researchers, hence the relational table.
Desired output:
Name Number of Submission
John Doe 14
William Smith 10
Ellie Carter 12
Susan Wright 10
Simply JOIN
the tables and do a group by
:
select r.FirstName, r.LastName, count(*) as no_of_sub
from Researcher r
join ResearcherSubmission rs on r.ResearcherID = rs.ResearcherID
join Submission s on s.SubmissionID = rs.SubmissionID
group by r.FirstName, r.LastName
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.