Skip to content
Advertisement

SQL to select records from multiple table using joins

I want a SQL select query for below scenario. I have 6 tables.

1) University

  • Univ_id
  • University_Name

2)College

  • College_id
  • College_Name
  • Univ_id (FK)

3)Department

  • Dept_id
  • Dept_name
  • College_id (FK)

4) Subjects

  • Subject_id
  • Subject Name

5)Student

  • Student_id
  • Student_name
  • Dept_id (FK)
  • Subject_id (FK)

6)Student_Subject

  • Student_id (FK)
  • Subject_id (FK)
  • Marks

I want the sum of marks for per Subject and per University. Please suggest and SQL statement for the same.

Advertisement

Answer

This should work:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement