0

So the problem I've been given is this: List of all course numbers and course description and if the course has a prerequisites, the prerequisite’s course name and number.

The table includes course_no, description (name of the course), cost, prerequisites. I know I need to compare the prerequisites to the course_no since the prerequisites contains the course_no for the course the student must have completed.

I cannot for the life of me figure out the subquery in order to compare to the two and return the description of the prerequisite course.

Any help?

1 Answer 1

0
select Course_No,course_Name,
isnull(prerequisite_course_name,'No Prerequisite') as prerequisite_course_name,
isnull(prerequisite_course_no,'No Prerequisite')as prerequisite_course_no 
from course A 
left join Course_Prerequisite B on A.Course_no = B.Course_No

Does this help?

6
  • yes and no. so if I got course A and course B, I need to compare a.prerequisite to b.course_no and then output b.description as the description for a.prerequisite
    – JStudz
    Dec 6, 2013 at 3:16
  • I suppose you have two table, Course and Course_Prerequisite. Then you join the two table to get description. Isnt that all the requirement? Anyway you have any sample format of tables you have and output you expected?
    – vasin1987
    Dec 6, 2013 at 4:09
  • it's just one table course with the columns course_no, description, cost and prerequisite
    – JStudz
    Dec 6, 2013 at 12:17
  • Can you provide sample of output you wanna see? I cant imagine what it
    – vasin1987
    Dec 7, 2013 at 9:40
  • Course_no Description PreReq Description 25 Intro to Programming 140 Structured Analysis That's what I'm looking for. So the preqreq # and description match, prereq is a course_no
    – JStudz
    Dec 9, 2013 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.