Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get Common Column value for multiple rows

SELECT f1.FacNo, o1.CourseNo, f1.FacSupervisor 
from Faculty f1 
INNER JOIN Offering o1 on o1.FacNo = f1.FacNo AND o1.OffYear = 2017

enter image description here

is it possible to write a query which returns rows whose FacNo and FacSupervisor CourseNo are same?

I was hoping to do this without any loops or sorts.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It’s not entirely clear to me what you’re asking, but this may get you close:

--original query
SELECT f1.FacNo, o1.CourseNo, f1.FacSupervisor 
FROM Faculty f1 
INNER JOIN Offering o1 on o1.FacNo = f1.FacNo AND o1.OffYear = 2017
 -- further narrow results for offerings with a supervisor matching the faculty member
INNER JOIN Offering o2 ON o2.FacNo = f1.FacSupervisor 
    -- for the same year and course
    AND o2.OffYear = o1.OffYear AND o2.CoursNo = o1.CourseNo
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading